Comet to Follow Server Threads Progression

by Jose Maria ArranzDecember 21st, 2009

Joseph McCarthy from IBM Ireland has written a tutorial, “Using Comet for asynchronous user notification of autonomous server thread progression” about how to use polling and Comet (long-polling) in Java with the ItsNat Java web framework to asynchronously notify end users through web the progression of an autonomous thread (not a web thread) executing a long task in parallel. This article is “inspired” on this musing published here at Comet Daily and this complete example.

The problem selected is to calculate the PI number through Gregory-Leibniz series. This calculation takes significant time if you want high precision.

The objective of the article is monitoring via the web this server thread with no user interaction, periodically obtaining the estimated value and of course asynchronously notifying to the end user when the calculation has finished. As a bonus, the user can start and stop the server thread through web buttons.

The article has two parts/approaches:

1) In the first part the “polling” technique is used (through the use of a meta refresh directive) alongside Ajax to query the thread state, conventional page navigation technology to start and stop the thread and global variables to hold the thread and calculation states. No specific web framework is used (just servlets and JSPs).

2) The second part uses Comet (long-polling) provided by the ItsNat framework. In this case the application is a single page interface and the thread is only attached to the user’s page. In this case a CometNotifier object provided by ItsNat is “attached” to the web page and to the calculator thread.

Note: the original article has an annoying visual problem, to read it I recommend using MSIE 6 (yes in this case a non-W3C CSS compliant browser is great) or Firefox disabling styles (View/Page Style/No Style).

One Response to “Comet to Follow Server Threads Progression”

  1. Jose Maria Arranz Says:

    Formatting problems of the cited article have been fixed, use any browser to read it.

Copyright 2015 Comet Daily, LLC. All Rights Reserved