Adding SSE support in Java EE 8

SSE (Server-Sent Event) is a standard mechanism used to push, over HTTP, server notifications to clients.  SSE is often compared to WebSocket as they are both supported in HTML 5 and they both provide the server a way to push information to their clients but they are different too! See here for some of the pros and cons of using one or the other.

For REST application, SSE can be quite complementary as it offers an effective solution for a one-way publish-subscribe model, i.e. a REST client can 'subscribe' and get SSE based notifications from a REST endpoint. As a matter of fact, Jersey (JAX-RS Reference Implementation) already support SSE since quite some time (see the Jersey documentation for more details).

There might also be some cases where one might want to use SSE directly from the Servlet API. Sending SSE notifications using the Servlet API is relatively straight forward. To give you an idea, check here for 2 SSE examples based on the Servlet 3.1 API. 

We are thinking about adding SSE support in Java EE 8 but the question is where as there are several options, in the platform, where SSE could potentially be supported:
  • the Servlet API
  • the WebSocket API
  • JAX-RS
  • or even having a dedicated SSE API, and thus a dedicated JSR too!
Santiago Pericas-Geertsen (JAX-RS Co-Spec Lead) conducted an initial investigation around that question. You can find the arguments for the different options and Santiago's findings here.

So at this stage JAX-RS seems to be a good choice to support SSE in Java EE. This will obviously be discussed in the respective JCP Expert Groups but what is your opinion on this question?

JAX-RS looks like a good fit, making it easy to provide links to e.g. CRUD notification channels from resources.

The main issue I see though is that this could encourage many simultaneous SSE connections which would quickly use up all the available browser HTTP connections.

Are there any thoughts on multiplexing to avoid this?

Posted by joeg on May 28, 2014 at 07:52 AM PDT #

I would like to see JAX-RS limited only to REST based services. A standalone standard for SSE like websockets would be a far cleaner approach.

Posted by guest on May 29, 2014 at 11:44 AM PDT #

It is nice to leave Jax-RS limited for webservices and to make a dedicated standard for SSE. I am waiting this feature from june 2013. I hope to see a dedicated specification of SSE.

Posted by guest on May 31, 2014 at 01:46 AM PDT #

I think SSE is way overdue in JavaEE. I concur with the second comment; the SSE should be flexible enough to use in either JAX-RS or just in Servlet.

Posted by chuk on June 18, 2014 at 09:02 PM PDT #

Post a Comment:
Comments are closed for this entry.