24 September 2012

ServerSent-Events on WebLogic Server

In addition to the WebSocket support we've added into the next major release of WebLogic Server (version 12.1.2  with all usual caveats with respect to release timeframes, no guarantee, etc.) we've also added support for the HTML5 ServerSent-Event model through collaborating with the GlassFish team and integrating the GlassFish ServerSent-Event feature.

The HTML5 ServerSent-Event model provides a mechanism to allow browser clients to establish a uni-directional communication path to a server, where the server is then able to push messages to the browser at any point in time. 

A common JavaScript API (EventSource) is provided in modern browsers that allows the client to establish connections to the server and register callback functions to handle events as they come in over the connection, which can then be used to make any necessary page updates.

Some good sources of information on ServerSent-Events/EventSources are:
This new feature in WebLogic Server and GlassFish provides a small Java API and a couple of annotations that developers use to create and publish ServerSent-Event handlers, from which applications on the server can use to send messages to connected browser clients at any time, essentially enabling applications to push messages to clients over standard HTTP(S).

The runtime component of the feature uses CDI to instantiate and manage the handlers and support the injection of them into other application components as well as setting up and managing the asynchronous connection for each client.

Jitu from the GlassFish team provided some information on the feature earlier in the year:
Bhakti also from the GlassFish team has a posting with an example of a SSE application that fetches data from a twitter feed and republishes to clients:
Here it is running on a development build of WebLogic Server 12.1.2.


Besides being an interesting new feature with lots of possibilities, this also serves to demonstrate how the WebLogic and GlassFish teams are cooperating and producing innovative outcomes.



18 September 2012

WebSockets on WebLogic Server

We've been busy working on putting in support for the WebSocket Protocol into WebLogic Server with the intent to include it in the next major release (usual caveats apply with respect to dates, times, features, etc.).  Running the Autobahn WS Testsuite, which seems to be the industry defacto WebSocket compatibility verifier, we are seeing reports with very high levels of compatibility.

As there's no standard WebSocket Java API at this point, we've chosen to model the API on the Grizzly WebSocket API with some minor changes where necessary.  Once the results of JSR-356 (Java API for WebSocket) becomes public, we'll look to implement and support that.

In the background we have also done some integration work with the earlier WebSocket-SDK that was being used as a vehicle for WebSocket API investigations in order to try it out and look at the SPI requirements -- but we won't expose it in WLS 12.1.2 and will wait for the formal Java API for WebSocket to be finalized.

Back to WLS 12.1.2 and it's WebSocket API, as an exercise, I just ported the Apache Tomcat WebSocket demo called snake to run on WLS.

The original Tomcat demo source is here:

http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/
 
Here it is running on a development build of WebLogic Server 12.1.2.


There are some differences in terms of handling of connections and the registration approach but it was a pretty straight forward exercise and took about 30 minutes.  The demo didn't require too many major changes as the APIs are semantically similar in terms of accepting connections, handling messages and sending/broadcasting messages to clients.  Thankfully I didn't have to do anything on the client JavaScript side ... :-)

We also have the Grizzy/GlassFish Chat demo running on WLS as well.



 More info to come as we progress the documentation, etc.  Should be some demos of this running at OOW this year too I'd guess.