As web applications become more and more a rich clients like, the need for html/http based server push notifications become increases. As a GWT developer, I found a very interesting document in the server push FAQ from the google web toolkit incubator wiki pages explaining different approaches and some of common server push pitfalls:
Because of the reasons explained in previous sections, the most scalable, compatible way to implement server push is the Wait, Respond, Close, Re-Open paradigm:
- Wait: When the GWT code makes a call to your server for some data that you don’t have yet, freeze (wait)
- Respond: Once the requested data is available, respond with it
- Close: Then, close the connection.
- Re-Open: Once your GWT code receives the response, immediately open up a new connection to query for the next event.
Further looking for GWT implementations I came across several projects, more or less alive, but his one here catched my attention: GWTEventService:
GWTEventService is an event-based client-server communication framework. It uses GWT-RPC and the Comet / server-push technique. The client side offers a high-level API with opportunities to register listeners to the server like to a GUI component. Events can be added to a context/domain on the server side and the listeners on the client side get informed about the incoming events. The server side is completely independent of the client implementation and is highly configurable. Domains can be defined to decide which events are important for the different contexts
From a web development view today, trying to implement server push notification means to fight both, browsers and servers, at the same time. The future looks promising from a standards perspective: HTML5 solves the client side of the fight, and Servlet 3.0 does the server side magic. Now, let us be realistic, when will we have those? I was lately asked about “the java web framework to use for the next 10 years, lots of eye candy, RIA, on IE6 and IBM Websphere 6.x”.
In the meantime, as long as we don’t really have HTML5 or Servlet 3.0, why don’t have a look here:
Atmosphere is a POJO based framework using Inversion of Control (IoC) to bring push/Comet to the masses! Finally a framework which can run on any Java based Web Server, including Google App Engine, Tomcat, Jetty, GlassFish, Weblogic, Grizzly, JBossWeb and JBoss, Resin, etc. without having to wait for Servlet 3.0 Async support or without the needs to learn how Comet or WebSocket support has been differently implemented by all those Containers.
Both projects offer fall-back options when running on non “older” runtimes (browsers and servers). It still tastes bad, but at least we have the new programming model running on the old infrastructure… Peeking into the future, there are some very interesting articles in the cloud:
Server push notification from scratch, very interesting:
This article shows how to put some pieces together from the Servlet 3.0 point of view:
Looking forward to HTML5 we get a standard (WebSockets) for two way server communication, here is a two part article on this topic: