• October 15, 2008

Real-time Updates on Web Pages - WebLogic Server 10gR3 New Feature

Guest Author

I was excited to learn via the popular blog TechCrunch that FriendFeed announced a beta of "Real-time" updates for their html pages using long polling or server push.  This is showcased on a page highlighting the Presidential debate.  One of the quotes I like was from Robert Scoble who said “This is wild. It’s like the web has been turned into a chat room.”


Why is this relevant to WebLogic Server and enterprise customers?  Well, you can build sites like this using WebLogic completely with out of the box features that are also enterprise-ready.  WebLogic Server 10gR3 now includes an enterprise class HTTP Publish and Subscribe Server that implements the Bayeux protocol. This protocol provides the ability to apply the Ajax concept known as Comet. This means that simple web clients based only on html and javascript can be notified nearly instantly as events are observed by the server; no Applets, Flash, or Silverlight required.

The HTTP Publish and Subscribe Server takes advantage of the groundwork laid in previous releases with the Future Response Servlet and Abstract Asynchronous Servlet.  A stock tracking example ships with the server shows real-time updates to market data directly in the browser and on a chart.  Click the image to enlarge.  When you see this example in action, observe that the stock ticker properties and chart are truly "live" and are constantly changing with new market data updates.

Consider how often this comes up in web applications.  I'd be shocked if you've never found yourself repeatedly hitting refresh on your browser to
    - check the status of an online auction
    - try and buy tickets to popular concert at a ticket broker that had a waiting room
    - see whether your stock trade went through
    - see if you have new web mail
    - see if new articles have been posted on a busy news site

Just like the manual refresh situations described above, many web applications have handled stale data checks by automatically refreshing the entire page.  MyYahoo and DrudgeReport are both extremely popular sites still perform a periodic complete refresh.  Ajax has helped improve this situation to some degree by providing a mechanism to only update a page partially without a complete page refresh, which can be faster and more efficient to the client, network, and server resources than request all the page resources again.  However, the AJAX technique often involved periodic server polling techniques, asking the basic question over and over again, "Anything new yet?".  The quicker the page needs display new updates, the more often the client still needs to check for them.  It should remind you of the long road trip cliche "Are we there yet?"

This can result in very inefficient behavior creating a lot of unnecessary network traffic and server load. Creative javascript and server-side developers started coming up with ways to push server events to clients using standard HTTP.   One of the members of the Dojo Toolkit javascript framework coined the term Comet, a play on the Ajax name, to describe the concept.  With the Bayeux protocol, they have found a way to mitigate some of the concerns polling to make it more efficient on the client and server.

In fact, many applications are now being built that take advantage of Comet techniques.  Take a chat application for example, Google Talk, YahooIM, and Meebo all have basic html and javascript clients that can participate in live chats.  In fact, previous versions of WebLogic Server included a chat example that applied this technique in a raw way.  See my previous post about it.

You can find the information about the stock example and run it with the samples domain.

- Note, use IE or another non-FF browser as the sample application does work with latest version of Firefox, I tried FF 3.0.3. The reason is that the html client code uses an old version of the Dojo Toolkit (0.4) that no longer behaves nicely with FF3.  You can tell that this sample was actually built awhile ago in web time. Several new Dojo releases have come out since then, as of this post the latest is 1.1.1, but it's still useful for demonstrating the concept.

A sample application I created with Dojo 1.1.1 worked fine in both IE and Firefox.  I'll plan on writing about in a follow-up entry as there is enough to say to make this a series of posts.  Dojo and WebLogic together provide a very compelling solution, but there are other javascript frameworks out there like JQuery that are also providing client software for this and the WebLogic implementation is compatible with any Bayeux client.  More to come soon.

Join the discussion

Comments ( 2 )
  • artemv Wednesday, October 6, 2010
    Hey James,
    does WLS uses "continuation" style of releasing threads like Jetty or WL guys invented their own way on how to support 10 000 comet users?
  • james.bayer Wednesday, October 6, 2010
    I believe it's fundamentally similar to Jetty continuations, but WLS leverages it's own implementation of something called the Abstract Asynchronous Servlet, which has an implementation called Future Response Servlet. See this documentation for some detail:
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.