Mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Comet API
Date Sat, 01 Oct 2011 00:37:02 GMT

I was reading the Comet API documentation, that is "aio.html" in the
docs and Javadoc of catalina.comet.* classes.

Here are several notes.
- #setTimeout():
 a) @param timeout says it is positive value.

With recent Mark's fixes to timeout handling it also accepts "-1" as
the infinite timeout. It works great with Nio.
(I'll add setting -1 timeout to ChatServlet.).

With Http11AprProtocol you cannot set timeout: the method throws

I think the value of "0" shall still be undocumented (I do not know
what it will do and it does not seem to be useful), so just "-1" can
be added.

b) Javadoc here says:
     web application SHOULD NOT attempt to reuse the request and
response objects after a timeout
     as the <code>error(HttpServletRequest,
HttpServletResponse)</code> method indicates."

It contradicts with description of EventSubType TIMEOUT here and in
aio.html, that says that this event is not fatal and
"the connection will not be closed unless the servlet uses the close
method of the event".

c) I am not sure whether setTimeout() can be called in READ event. The
Javadoc here says just that it cannot be called outside of events
("asynchronously"), but aio.html explicitly mentions that BEGIN event
should be used to call setTimeout().

d) In "Comet timeouts" section in aio.html it is said that the default
timeout for "soTimeout" for Nio and "soTimeout*50" for Apr. I have not
looked where it is actually set in the code,  but in HTTP Connector
documentation there is not attribute "soTimeout"

- #close():
a) "The servlet should perform any needed cleanup as if it had
received an END or ERROR event."

Does it need to perform the cleanup?

The description of EventType.READ event here and in aio.html also
mentions to perform cleanup before calling cose().

>From description of SESSION_END subtype of END event my understanding
would be that
it would receive it (maybe unless it was called in END or ERROR
events) and could cleanup there.

So, what SESSION_END is for?

- (Javadoc for EventType, EventSubType has no <p>,<br> and thus will
be unreadable.)
- (In SESSION_END do s/session/Comet session/ and do the same
replacement in aio.html, to avoid ambiguity).

a) ("When this interface is implemented, the service method of the servlet will
 never be called".

-Actually the service() method will be called - It is called if the
connector does not support Comet,
as ChatServlet example shows. The same applies to CometFilter as well

a) Is CometEvent object available only as an argument of the event() method?

Can it be stored by cometprocessor between the events that it receives?
Or only HttpServletResponse and HttpServletRequest can be stored and
reused between events?

Thus, can a servlet call the CometEvent.close() method while it is
between events?

b) Can CometProcessor#event() be called for several events for the same
request&response pair at the same time? I guess that it cannot happen.

c) It is said "At any time, the servlet may end processing of the
request by using the close method of the event object."

Nothing is said about such methods of Servlet API as
OutputStream.close(), InputStream.close().
I guess they should result in receiving an END event, and in the END
event the sevlet will call CometEvent.close() to stop Comet

d) It is good to know that many Response methods will throw
IllegalStateException as aio.html clearly says that the response is
committed after BEGIN event.

What if we never called flush() on the output stream? Is it still "committed"?

If it is committed only "after BEGIN event",
can the servlet or filter call response.sendError() while it is in BEGIN event?

e) If a Connector is stopped, will it be SERVER_SHUTDOWN subtype of END event.
Though I think that during shutdown maybe WEBAPP_RELOAD will come first?
Will the event come if connector is stopped through JMX?
When a web application is stopped will it be WEBAPP_RELOAD?

Can these events come asynchronously with regards to other
BEGIN/READ/END/ERROR events for the same request&response pair?

Best regards,
Konstantin Kolinko

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message