Hi, I am trying to use NIO HTTP Tomcat connector org.apache.coyote.Http11NioProtocol to implement Comet streaming to browsers and mobile devices (using Tomcat org.apache.catalina.comet.CometProcessor). The application opens a persistent Comet connection to receive data from the server. Server then sends data to the client periodically.
My server application has several threads to send data to the clients. One thread is assigned a set of clients. It will be possible that one of the clients is "slow reader" for various reasons. If I call PrintWriter.print("message") to send data to such client, the thread apparently may block causing all clients assigned to the thread to stop receiving updates. Clearly, this is not going to fly and I need to make some changes to address it. I am looking for 2 things: 1) I need to understand threading for Http11NioProtocol/CometProcessor. Are there any articles/ docs describing how it works? Could someone point me to it? It will help any developer using this in the future if it is properly documented. Apparently there are buffers associated with clients. There is a buffer of 32K(?) associated with the client that causes writes to block when full (?). Mark Thomas gave me some pointers, but I am still far from understanding the whole picture. 2) I need to detect if client is "slow reader". I do not see any way to do it besides accessing the client queue and checking its size. Will it be possible to expose it in the Comet API? I should be able to configure its size and disconnect clients with queue reaching a threshold. I suppose I can spawn a thread for each client, but this is ugly. Any suggestions will be appreciated. Thanks