Friday Dec 20, 2013

Server Sent Events (SSE) in Glassfish/Jersey

As you know, HTTP is a stateless protocol. For most use cases in the enterprise, the statelessness of HTTP is a huge boon for scalability - a benefit that is also extended to REST. However, there is a certain class of arguably emerging use cases for which the stateless nature of HTTP is actually a scalability challenge. These use cases require the bidirectional, full-duplex, asynchronous characteristics of stateful protocols such as TCP. Examples include chat-like online collaboration, stock-ticker like command-control/monitoring, online gaming and the like. WebSocket (and the Java API for WebSocket newly included in Java EE 7 :-)) is ideal for these cases. Between the seemingly diametric opposites of plain HTTP and WebSocket, there's also Server Sent Events (SSE). SSE is aimed at yet another scenario - a steam of events generated by the server and consumed passively by the client. Although not standardized in JAX-RS 2/Java EE 7, Jersey/GlassFish includes support for SSE.

In an very detailed blog post, Rahman Usta of the Istanbul JUG explains SSE and demonstrates a non-trivial use of the Jersey/GlassFish support for SSE.

Tuesday Apr 24, 2012

Server Side Events with HTML 5 and GlassFish

While this is not the first post on Server Side Events,  Bhakti and Jitu continue the discussion of using Server-Side Events (SSE) as HTML 5, Java EE 7, and GlassFish Server move full steam ahead.

The blog posts include example source code that can be deployed to recent (trunk) builds of GlassFish Server.  Bhakti uses SSE and CDI to build an application that tracks a twitter search, while Jitu discusses how GlassFish adds a bit more abstraction for the developer and references a video player sample application available in the GlassFish trunk.