The Problem. But what if you want to build a highly interactive application that adds updates to your page as soon as someone half way around the world updates theirs? What if you are in a CMS interface and you go to check out some content and find you colleague in marketing checked it out 2 minutes ago, but the page you are looking at hasn't been updated since then? What if you are writing an article on Reverse Ajax using Writely and your technical editor just updated the paragraph you were going to work on? These are essentially monitoring and multi-user applications. The browser does the asking. The problem is that web servers can't easily contact web browsers. For one thing firewalls will get in the way, and even if they didn't, browsers only listen for answers to questions they've asked. So how is the web server to get the message through?As the article explains, Ajax is traditionally a mechanism by which a browser pulls data on an ad hoc basis from a server. However, Joe Walker's DWR library has implemented Reverse Ajax, which is an implementation of three techniques for providing updates to a browser on a regular basis: browser polling, long-lived HTTP requests (the 'Comet' approach), and piggybacking responses (in which the response for one Ajax request is delayed until the next Ajax request is made from the browser).
News: Jonathan Downes on "What is Reverse Ajax?"
Jonathan Downes has written an article called "What is Reverse Ajax?," addressing the definition of this 'new technique' - which is actually a set of older techniques combined under a single name, much like Ajax itself is.
- Posted by: Joseph Ottinger
- Posted on: May 25 2006 07:18 EDT
- What is Reverse Ajax? - Easy by John Davies on May 25 2006 19:01 EDT
- Re: Jonathan Downes on "What is Reverse Ajax?" by Sergey Smirnov on May 25 2006 19:32 EDT
- Re: Jonathan Downes on "What is Reverse Ajax?" by Ted Goddard on May 26 2006 11:25 EDT
- Re: Jonathan Downes on "What is Reverse Ajax?" by Roger Voss on May 27 2006 18:49 EDT
- Re: Jonathan Downes on "What is Reverse Ajax?" by Ravi Chamarthy on May 29 2006 00:57 EDT
- Don't think that it is important to coin more buzzwords by Frank Nimphius on May 29 2006 06:03 EDT
- Lightstreamer for Reverse Ajax by Alessandro Alinone on June 19 2006 02:59 EDT
- Try StreamHub for a Mature Reverse Ajax Server by Comet Dude on August 20 2009 19:45 EDT
Xaja! :-) -John-
One more bastion is fallen. We are living in very interesting time when features that used to be considered not for web becomes publicly announced as features of thin client. I am not going to be wonder if somebody announce how to disable that annoying back button and keep the connection alive after user closes the browser for a coffee break :-) Anyway, thanks to Jonathan to classify the new technique features. Now, we have some job to do. Sergey: https://ajax4jsf.dev.java.net/
For ICEfaces we're now calling this feature "application-initiated" AJAX. Originally (such as at JavaOne last year) we were simply calling it "Asynchronous", but taking Asynchronous to its fullest extent. That is, network operations are fully decoupled from user actions -- not only does the browser not lock up when you send a message to the server, the server can send a message to the browser independently of what the user does. The ability for the application on the server to update the page at any time is what makes AJAX revolutionary -- it turns the web into a new communication medium.
A few geological eras ago "reverse Ajax" was simply referred to as server-side push. Indeed, back in the primeval times of the Internet, Netscape devised a protocol specifically for server-side push of data over an HTTP connection to a browser. It may be hard to believe for some but this old Netscape protocol has been in use ever since. For instance, in my software applications I support streaming MJPEG video from a Panasonic NT109 video encoder that uses this Netscape protocol. Any Netscape, Mozilla, or Firefox browser can HTTP connect to this video encoder and start receiving streaming video directly in a plain web page. (IE users are out of luck - the first frame of image data and then nothing.) The Axis video encoder uses a very similar protocol but alas is slight different for the frame separators so hence their ActiveX control has to be used to receive their MJPEG. The Wikipedia also has a definition for this. It refers to it as HTTP Streaming. This definition is just the general notion of leaving an HTTP connection open to the client so that the server can continue to send subsequent notification data to the client. Again, an IE browser will have to reopen the connection after ever message is received on an XMLHttpRequest connection, while any of the Netscape/Mozilla/Firefox family of browsers will be able to receive messages indefinitely over the same open XMLHttpRequest connection. The Wikipedia HTTP Streaming concept does not mandate any particular message body separator as did the old Netscape server-side push protocol.
BTW, if you implement HTTP Streaming and you want to support the IE browser (which has the problem in that it closes an XMLHttpRequest connection after response data is received), then is best to implement message queuing over on the server-side. That way an IE browser will not miss any important messages during the time it is disconnected and has to re-establish its HTTP Streaming connection via XMLHttpRequest. So if you're now going to have to have message queues so that the client browsers never miss seeing their notification messages, well you might as well leverage JMS for that. You're JEE app server has JMS as its part of the JEE spec. Server-side code will then simply publish JMS messages to a JMS queue or topic in order to push out notifications to web browser clients. Okay, now we're essentially talking about devising a message bridge between lots of web browser clients and a JMS messaging server. And because we're going to do this over the Internet we need to support thousands of simultaneous, persistent XMLHttpRequest connections per a physical server. Hmm, we need to dump the traditional tomcat servlet engine that consumes a thread per each connection and instead devise a server based on Java NIO. Then we can scale up to 10000 concurrent, persistent connections per physical server (we'll only need a relative handful of connections that connect on over to the JMS server). So this special HTTP Streaming server uses Java NIO to manage XMLHttpRequest connections on the front-side of the message bridge and then traditional Java IO connections to the JMS server on the back-side of the bridge. We'll work some soft of memory pipe and make use of Java Concurrency Executor thread pools to mediate the bi-directional transfer of message data. Well, turns out Sun at JavaOne was promoting their Grizzly NIO framework - which they used to build their Glassfish JEE application server - as a general purpose, open source endeavor. So there you have it. Grab Grizzly and build yourself an HTTP Streaming server so that AJAX web applications can enjoy bi-directional JMS messaging. Starting with Grizzly should save about 3/4 if the overall effort.
Looking closer to the 3 techniques, as put forwarded by DWR Polling -- There is hardly anything to speak about Polling technique, as this is a age old technique for getting the updates from Server, but this is not a true Server Push technology and only an alternative. Also, the client should be intelligent enough to know when the data is available at the server side to poll the data. Comet, long lived Http, or the slow load technique -- You would always see the annoying message something like "Waiting for xyz.com..." as the browser status and the page always, indefinitely, loads the page. I really wonder about the scalability for number of connections. PiggyBack Technique: Here the server, having an update (or for that matter a bucket of huge updates) to send, waits for the next time the browser asks it a question and blows out the updates, and hence the answer. This looks like a refined polling technique where the Client should, again, be intelligent enough to know when to ask the server for the new data. Are these 3 techniques really server push? Ravi.
You don't make a technology interesting by coining more buzzwords. If you think that Reverse Ajax is needed then here are my suggestions for more unnecessary acronymns Ajax-WS for - Ajax with Web services Ajax-ACID - for transactional Ajax Ajax-Reliability - to ensure reliability of execution or asynchronous Ajax requests Ajax-Security Ajax-I - for interoperability of Ajax with browsers etc. Frank
Or how about Ajax Push? Paul
Useful recap on this topic. Just to add a reference to actual solutions, Lightstreamer (www.lightstreamer.com) is a mature product that has implemented "Reverse Ajax" for five years (of course with a different terminology... :-)). Just look at the online demos to glance at Reverse Ajax. For a paper that compares the different paradigms to implement Reverse Ajax, refer to Changing the Web Patadigm.
If you're looking to implement reverse ajax or comet - I'd recommend you take a look at StreamHub Reverse Ajax Server.