With usage of APR or NIO APIs as the basis of its connectors, Tomcat is able to provide a number of extensions over the regular blocking IO as provided with support for the Servlet API.
Comet support allows a servlet to process IO asynchronously, receiving events when data is available for reading on the connection (rather than always using a blocking read), and writing data back on connections asynchronously (most likely responding to some event raised from some other source).
The section contains the sample code for this https://tomcat.apache.org/tomcat-6.0-doc/aio.html#Example_code
When some event occurs, the event() method is called back. There are multiple event types
CometEvent.EventType.BEGIN => Beginning of the session
CometEvent.EventType.ERROR => If there is any error in the session
CometEvent.EventType.END => end of the Event
CometEvent.EventType.READ => READ event
When the READ event is called back, application can read the stream by using the Input stream method.
References:
https://tomcat.apache.org/tomcat-6.0-doc/aio.html#Example_code
Comet support allows a servlet to process IO asynchronously, receiving events when data is available for reading on the connection (rather than always using a blocking read), and writing data back on connections asynchronously (most likely responding to some event raised from some other source).
The section contains the sample code for this https://tomcat.apache.org/tomcat-6.0-doc/aio.html#Example_code
When some event occurs, the event() method is called back. There are multiple event types
CometEvent.EventType.BEGIN => Beginning of the session
CometEvent.EventType.ERROR => If there is any error in the session
CometEvent.EventType.END => end of the Event
CometEvent.EventType.READ => READ event
When the READ event is called back, application can read the stream by using the Input stream method.
References:
https://tomcat.apache.org/tomcat-6.0-doc/aio.html#Example_code
No comments:
Post a Comment