At my current project at work, we need the ability to push events/data to clients using a typical web application which already has some XHR elements in it. Our current approach has been to use a Java Applet and let it make a socket connection back to the web server. This persistent network connection allows us to send events to the client, independent of client’s own requests. However, this solution is not super clean, mainly because applets are old-school and it takes an insane amount of effort to maintain the applet-JavaScript communication.
So, I set up on a quest to find other technologies available for server side push, and came across Comet. Comet is essentially a style of programming that allows event-driven server-side push data streaming. The best example of Comet is Google Talk inside GMail. Zhou Renjian has already cracked this and created a plain JavaScript implementation. There is no dearth for implementations of this technology. However, none of those fit our needs exactly.
Fortunately, many web containers are already beginning to realize the value of such technology. Most of the major containers look like they will have support one way or another in the near future. Jetty is working on continuations. Tomcat is introducing a CometEvent. WebSphere is relying on DOJO. Weblogic has an AbstractAsynServlet.
In any case, I ended up using a persistent XHR connection between the server and the client. This worked like a charm, although I haven’t been able to test the scalability part of it yet. Fortunately , or unfortunately, our project does not have high performance expectations, and so it will take some more time until I can figure out the scalability aspect of this solution.
