Comet: Reverse Ajax for streaming data from the server

Discussions

News: Comet: Reverse Ajax for streaming data from the server

  1. Daniel Rubio (who maintains the blogs section for TSS.com) has written an article called "Comet: Reverse Ajax for streaming data from the server," describing 'Comet,' a technology to push events from the server side to a browser client. Comet manages to avoid the issues related to having a browser poll a server to check for new events.
    The first thing you need to realize is that the data service on the serverside needs to be designed to hold state on behalf of browsers clients, a process that can either be very difficult or very easy, depending on the platform and language you are using. Once again, this takes us to the stateless nature of Web applications and the way a browser needs to identify itself constantly either via cookies or session IDs, or what some characterize as the Hollywood principle – "don't call us we'll call you" – referring that only a browser is equipped to make calls and never vice-versa. This last issue takes us down the road of building an asynchronous server application, or if you prefer a fancier name, an HTTP-based event routing bus, or in other words, a latent application on the serverside able to keep track of clients wishing to receive updates, a design very much in line with the messaging systems used in enterprise systems that are based on publish/subscribe channels. However, since this last mechanism represents a departure from the "bread and butter" approach used in most Web platforms, it is a big reason why most Comet applications today rely on either custom adapted application-servers or embeddable versions that can tackle these issues. In the particular case of Java, Jetty and Grizzly are two servers that currently have out-of-the box support for Comet-type designs, with varying support in other languages like Python and other popular Java servers like Tomcat, for what is technically known as "continuation support," a paradigm by which applications are shielded from the stateless nature of the Web. Continuation support also is a touted feature of higher-level language Web frameworks written in Smalltalk and Lisp that have this capability. Turning our attention to the client side of things, a browser can take various routes to stay in contact with these type of server applications. Among these approaches are long-polling, dynamic script tags and inclusively a workaround using IFrames, none are standard approaches by any means, which is yet another reason why many client side Comet designs rely on the use of frameworks to abstract away incompatibilities between browser implementations – similar to Ajax – with one such framework being Dojo, which in itself now serves as both an Ajax/Comet framework.
    Of course, the term Comet itself is something to wonder about. AJAX' meaning is fairly well-known, as "Asynchronous Javascript and XML," but what about Comet?
    As far as the actual term is concerned, Comet emerged as a pun to Ajax's meaning outside IT circles as a household cleaner. But quirky name or not, Comet is serving the purpose of an umbrella name for delivering data onto browsers as it becomes available on the serverside, a technique that will surely be of the same impact and go hand in hand with what we know today as Ajax.

    Threaded Messages (12)

  2. Resin also has support for this since 3.1.3 BR, Robert
  3. Also, the Resin examples emphasize more of a message/event-oriented design, with the comet servlet itself acting more like a JMS topic subscriber. There's a JavaScript example and a Flash example using Resin with a trivial event-generating service.
  4. and[ Go to top ]

    and Resin also works even w/ ActionScript. http://hessian.caucho.com/comet - which is what we use. Much faster then XML, jSon, and wider support. I suspect it's faster then amf3. Comet is in some ways similar to JMS. I wish Java JRE had built in API for applets to help drive adoption. .V
  5. When programming Adobe Flex RIA web applications, the BlazeDS messaging component can be used on the server side to push messages to Flex clients. BlazeDS supports the Comet pattern and uses the long polling approach. Sources with Adobe have conveyed to me that it will support more efficient implementations of Comet by modifying it's servlet to support such as Tomcat 6 Comet Events. Jetty and Tomcat have a different approach to the Comet pattern and that being the case, Adobe has to seek out an approach that will support these variations - the one reason it is currently not doing so in its beta release. When using Comet Events with Tomcat 6, the Java NIO HTTP listener needs to be configured for use - instead of the default HTTP listener. BlazeDS supports a JMS adapter, so it can be tied right in to a message broker such as ActiveMQ, et al. Consequently a Flex client can ultimately be proxied (via BlazeDS) as a subscriber to a JMS topic. Or can send messages to a JMS queue. Consequently Flex clients can very easily become full participants in an enterprise JMS-based messaging bus. This is very powerful stuff indeed for the likes of web browser based applications.
  6. Yes you should download BlazeDS, it's free. And then look at all the config to get it to even hello world. Hessian, also a binary protocol was very easy to get to work. You can for example do junit in java, before Flex or Flash. Hessian is also likely to work w/ SilverLight. Comet is to be included in the next spec of Servlet, there fore all Java containers will support it. .V
  7. BlazeDS supports a JMS adapter, so it can be tied right in to a message broker such as ActiveMQ, et al. Consequently a Flex client can ultimately be proxied (via BlazeDS) as a subscriber to a JMS topic. Or can send messages to a JMS queue. Consequently Flex clients can very easily become full participants in an enterprise JMS-based messaging bus
    The Bayeux protocol maps pretty closely to JMS pub/sub. So web client to msg bus connection should be pretty straightforward, regardless of the particular server implementation sitting in the middle. Glad to see BlazeDS can connect out via JMS. Does it support Bayeux as well?
  8. HTML 5 Server-sent Events[ Go to top ]

    Server-sent events provide a nice standardization for Comet. Ideally, that standard should be available across all RIA technologies (i.e. JS, Flex, Silverlight, etc.). Luckily, Kaazing Gateway (http://www.kaazing.org) provides a server to scale server-sent events (as well as websockets). It also provides an emulation layer that does not require a plugin that can be used to adapt any browser to consume server-sent events.
  9. Pushlet[ Go to top ]

    Remember 7 years ago or so when they were calling this "pushlets"? http://www.pushlets.com I'd prefer to lose the silly mnemonic and stick with calling it what it really is: a hanging-GET.
  10. Re: Pushlet[ Go to top ]

    Remember 7 years ago or so when they were calling this "pushlets"? http://www.pushlets.com

    I'd prefer to lose the silly mnemonic and stick with calling it what it really is: a hanging-GET.
    +1 - nix the branding for the technical concept. Every future discussion of (article-about) 'comet' will require an explanation of the term in the context of web development as part of its preamble. Comet on Wikipedia
  11. Comet & Prototype[ Go to top ]

    Folks, there's some intention of prototype having API facilities to comet model? Some prototype guy could answer this one? Rgrds, JV -- julioviegas.com
  12. You don't need a special application server for Comet, a special application server is needed if you have many concurrent users to avoid the problem of 1 thread - 1 request. For instance ItsNat supports Comet "out of the box" with any servlet container and any (modern) browser using AJAX long polling (online example) or AJAX timers (online example), some people include AJAX timers as a sort of Comet because it provides "real time" to the web (this depends if Comet="real time web" or Comet="server push", because "real time web" is more generic than "server push"). Neither you don't need to wait for HTML 5 to include "server-sent events", ItsNat provides a kind of server-sent events, very useful for functional testing.
  13. I think the most popular one these days is StreamHub Comet Server, it has support for .Net (VB, C#, C++) and Java for pushing data. It uses a JavaScript library to receive real-time updates on the web page. Completely cross-browser, I've tried it in Safari, Chrome, IE8, Firefox, even Opera. Worth checking out.