Praveen Balaji wrote:
The
last few days I have been evaluating using CometProcessor to work like an
Async Servlet for me. I pick up the CometEvent object on BEGIN event and
process the whole request asynchronously. When I am done, I close the I/O 
stream.
I
would like to know what the Tomcat developers and the developers in general
think about this approach. Is it a misuse of the API to process requests
asynchronously, outside of the event method? Are there any issues that I should 
be cautious about? Synchronization issues?


See the mailing list archive of the last month and filter on "comet". There have been quite a few posts on exactly this subject.

There are multiple issues:

1) Closing the I/O stream (on the response) does not end the request/response. It takes another 30-60 seconds before the event method gets called with an END event leaving a lot of request open unnecessarily.

2) Nothing is synchronized in Comet, so you have to do all synchronization yourself. You have to make sure that you do not write to the output stream after the event is closed (even though you may still have the reference in your asynchronous application code). I seem to have eliminated most issues by synchronizing access to the response output stream and using the same lock around the event.close() method in the event() method of the CometProcessor. However I still very sporadically get a ClientAbortException/ClosedChannelException which suggests that I've missed a place where synchronization is necessary. It might not be possible to synchronize this though, because it could happen deep inside Tomcat. The API has no information about what to synchronize for asynchronous use.

3) If you rely on the POST method to send parameters to your CometProcessor, then you have to parse the parameters yourself; there is an issue that doing getParameter() on the request in the BEGIN event may return null because the request body has not yet been received by the server at the moment of the getParameter() call.

One of the Comet developers (Remy) suggests that it might be better to just use normal servlets and buy some extra memory for the extra threads.

As far as the current API goes, I would say it is probably a "misuse", though I would very much like to see the API improved so that this is no longer the case.

Regards,
Sebastiaan

Thanks,
Praveen Balaji.




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to