Monday May 06, 2013

Integrating WebSockets and JMS with CDI Events in Java EE 7

One of the first things you will want to know about Java EE 7, is how you can integrate some of the new APIs like WebSockets, with existing ones like JMS. That's why I decided to write this article "Integrating WebSockets and JMS with CDI Events in Java EE 7". What I try to demonstrate here, is how two distinct APIs can be used together to deliver something that is not explicitely defined in the specifications, but with some cool integration using CDI Events, an async server-side data push can be implemented with no more than the standards at your hand.

The article will show you how to code your first WebSocket server endpoint, then how by using a Stateless SessionBean you can send messages to a JMS Queue, and finally, how to receive them again by using a MessageDriven Bean that fires CDI events with the payload back to the WebSocket. Simple, straightforward and small code, that takes you through several specifications and releases available starting from now, the Productivity++ Java EE 7.

Tuesday Apr 17, 2012

WebSockets and Java EE 7: JSR 356 Starting Up

Java API for WebSocket (aka JSR 356) will define a standard API for creating WebSocket applications. The Expert Group consists of RedHat, Google, Caucho, VMWare and other individuals like JeanFrancois Arcand and Justin Lee.


GlassFish has support for WebSocket using Grizzly on server and client for some time. The JSR will provide standards-based code to write WebSocket applications.

Danny Coward has started websocket-spec and you can read the EG discussions at jsr356-experts. The users@websocket-spec allows you to participate in the discussion. Of course, all this will be delivered as part of Java EE 7 which is now scheduled for Q2 2013.

How are you using WebSocket ? Would you like to join the EG and contribute ?

Wednesday Feb 08, 2012

Yet another Java EE 7 spec - WebSocket is JSR 356!

JSR 356 has been filed by Oracle : "Java API for WebSocket". The spec lead is Danny Coward and this JSR is scheduled for inclusion in Java EE 7

While it's great to have both server and client support for WebSocket in Grizzly and GlassFish, it's probably even better to have a standard to encourage portable code. The Review Ballot is scheduled to start on 21 Feb, 2012.


With this JSR, I believe the list for Java EE 7 is now complete. You can get the full list in the latest issue of the Java Magazine and catch recent posts using the javaee7 tag.

Thursday Mar 24, 2011

WebSockets support in GlassFish 3.1 (and Grizzly)

There is no need to wait for Java EE 7 or GlassFish 4.0 to use the WebSocket protocol. As we've covered in the past the bottom line is that you can use WebSockets today with GlassFish 3.1.


GlassFish 3.1 (Grizzly 1.9.32) implements the -76 version of the WebSocket Protocol and was used to created this series of screencasts. Justin has many more details on what can be done with the stable and supported release of GlassFish. This version of WebSockets is reported to be supported by Google Chrome 6, Safari 5.0.1, and Firefox 4.0 (although disabled by default).

As browsers move to implement newer versions of the WebSocket protocol, you'll need to get into bleeding edge territory (i.e. not supported) and use a more recent version of Grizzly. Either update GlassFish 3.1 to the fresh from the oven version 1.9.33 (see Justin' blog about this) or use grizzly 2.0 directly. The -06 version in particular is supported in 1.9.33. Whichever version you end up using, don't forget to enable support for WebSocket in GlassFish.

Check out also this recent slide deck from Justin.

Monday Oct 18, 2010

Another HTML5 and GlassFish Video: 2D APIs and Client SQL DB

More HTML5 from Santiago, this time showing how to use the 2D APIs and the client SQL DB APIs.

As previously, Santiago provides a Blog Post and sources, which should run on the latest GlassFish 3.1 Milestone and your favorite WebSockets-enabled browser (or device).

Santiago also provides a screencast, now available at GlassFishVideos as part of the new HTML5 playlist. The screencast is in HD, if you expand it into full-screen you can easily read the code in the NetBeans IDE.

PS. GlassFishVideos already has 44 videos; subscribe to get the notifications as we upload new content there.

Wednesday Oct 13, 2010

WebSockets and HTML5 on GlassFish

Santiago has started writing about HTML5 and GlassFish 3.

Last week he showed a simple Web application that controls an HTML5 video object remotely (post).  The example works using WebSockets connected from the server to two browser windows - playback activity in the master window is reflected instantaneously on the slave window.  Simple code but helps understand how these features can be used.

This week Santiago created a screencast (HD) based on that example and posted it to GlassFishVideos. I just placed it in a HTML5 playlist together with an earlier video from Alexis on WebSockets support in Milestone 2 of GlassFish 3.1.

I'll use this opportunity to capture a few key links on this area, hopefully it will save you some time.

HTML5 really is a collection of specifications, carried in different places: W3C, WHAT WG, IETF.  Some of the specifications relate to document syntax/semantics, some to (JavaScript) APIs, some to protocols.  The whole set is available as a (large) single document: Web Applications 1.0; a nice table is in the WHAT's FAQ: What are the various versions of the spec.

A good entry point is, which includes the specs for Web Applications 1.0, HTML 5 and Web Workers and plenty of other good content like FAQ and Wiki. HTML 5 properly describes the document format and semantics (Wikipedia,  WHAT's Editors Draft, W3C Editor's Draft). There are many HTML5 tutorials out there; I like Mark Pilgrim's Dive into HTML5 (avail under CC-BY-3.0 License).

Websockets (Wikipedia, API@W3C, Protocol@IETF) is the technology used in Santiago's example. Gregor Roth recently published a two part series that also covered WebSockets as well as Server-Sent Events, a higher-level API intended to manipulate the DOM from the server side.

Expect more HTML5 posts and videos; in the meantime, enjoy!

Update: some Twitter feedback suggested we tried the HTML 5 video enclosure, so we did! Feedback is welcome on how tit works for your browser and the video can be seen here on YouTube.

Thursday Apr 23, 2009

Recent web-tier activity: Metro 1.5, Grizzly 1.9.11/2.0, ...


The GlassFish web tier team is very active with releases and new features. Here's a quick set of links. JAX-WS spec and implementation lead Jitu announces the simultaneous releases of JAX-WS RI 2.1.7 and Metro 1.5 (Metro includes the JAX-WS implementation) and shares some of the new features and the list of bugs fixed.

In this blog post Jean-Fran├žois Arcand announces the availability of Grizzly 2.0 Milestone 1 and its main goals and shares a quick walk down memory lane on how the project evolved since its early days. Project lead Oleksiys goes into more details about the content of the release including an interesting strategy API for handling requests. Note that Grizzly 1.9.11 is the release integrated into GlassFish v3 (offering it a set of extension points).

Speaking of Grizzly, Jakub has an entry on using just GrizzlyWebServer 1.9.10 to serve both static and dynamic RESTful content with Jersey. Finally, in addition to the quite mature Comet implementation in Grizzly/GlassFish, Jean-Fran├žois' Atmosphere framework (now running on Weblogic!), HTML 5 WebSockets may well be on the list of things coming up next.