Home > SOA Tips > The Web Services Advisor > Comet: Reverse Ajax for streaming data from the server
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

Comet: Reverse Ajax for streaming data from the server


Daniel Rubio
Rating: -3.60- (out of 5)

Ajax, or Asynchronous JavaScript and XML, has become a household name in the area of Web applications, this mechanism by which a browser accesses a RESTful Web service and updates its GUI without a screen refresh, has spread from its pioneering roots in on-line maps and calendars to pretty much a standard feature in most new Web applications. However, it was...


RELATED CONTENT
The Web Services Advisor
Where does BPEL fit in?
Some notes on ESB configuration
Open source application development frameworks offer alternatives
What to expect with the new JavaScript standardization (ECMAScript 5)
Restlet framework wrestles RESTful Web applications
3 tips for choosing whether to use EGL
Use SoaML to facilitate Model Driven Architecture
Enterprise mashup patterns act as API enablers
XQuery learns to write using XUF
Descriptive Languages for RESTful Services

Ajax and RIA (Rich Internet Applications)
Ajax and RIA trends
Ajax tools and products
Ajax Tutorial
News and insight from The Ajax Experience 2009
Doloto tool said to speed large-scale Ajax applications
ECMAScript 5 takes JavaScript to a new level
Google Chrome Web browser: Is it an OS in waiting?
Kapow bows data-driven server for the enterprise
Enterprise mashup patterns act as API enablers
JViews enhances Eclipse RIA support
Ajax and RIA (Rich Internet Applications) Research

Data services for SOA
IBM announces expansion of mashup portfolio
SPSS and PMLL
Canonical Schema establishes interoperability: SOA Pattern (Week 6)
Medical imaging group build HL7 messaging hub with InterSystems Ensemble
Using atomicity to gain SOA granularity
Use JavaScript with the iPhone to create smart phone apps
Componentized XML Query tool takes a step forward
Podcast: SearchSOA tips on software architect skills
Services reuse drives ROI for SOA, survey finds
Tibco releases Complex Event Processing (CEP) suite with new rules, query interfaces

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Drupal  (SearchSOA.com)
evergreen  (SearchSOA.com)
Google Spreadsheets  (SearchSOA.com)
meta tag  (SearchSOA.com)
Prism  (SearchSOA.com)
Rich Internet Application (RIA)  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


not until recently that a new term was coined to complement this approach, one which is now often dubbed reverse-Ajax, its name: Comet.

In order to comprehend why one would need something like reverse-Ajax – or Comet – one need just look at the nature of real-time events, such as those occurring in the stock market or in sporting matches. Let's assume you are charged with creating a Web-based application with Ajax – as in no full-screen refresh – based on one of the aforementioned areas, what time span would you use for making new asynchronous calls to your data services? Remember, you don't want users to miss any new action in the game, or worse, miss a stock quote to place their orders.

This type of design has no easy answers, if you use too long an interval users might miss out on new information, on the other hand, if you use too short an interval it will likely flood your data service with unnecessary requests. At the heart of this issue is of course the stateless nature of Web applications, but there is one solution to this conundrum, the server notifying the client on the availability of new data, also often referred to as serverside push.

To those initiated in rich-client technologies like Flash or Java, this process – and even Ajax – might seem trite, especially since these last technologies have integrated mechanisms like remoting and streaming to deal with asynchronous requests from both client to server and vice-versa, but what Comet is all about is pulling off this last process using the same vanilla technologies as Ajax – namely JavaScript and HTML. So with that said, lets see how this design needs to be tackled.

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.

As a matter of fact, in this latter area there is already ongoing work in standards like HTML 5 to implement and natively support Comet-type payloads via a simple tag named , doing away in this case with the need of frameworks and fragmented approaches to display Comet-bound data. However, as is the case with most standard related issues, this is very much in the future and will be a reality once browser vendors get on the same page.

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.

About the author
Daniel Rubio is an independent technology consultant with over 10 years of experience in enterprise and Web-based software. He blogs regularly on these and other software areas.


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2010, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts