I have a CometProcessor implementation that is effectively doing a Multicast to a potentially large number of clients. When an event occurs that needs propagated to to all the clients, the CometProcessor will need to loop through the list of clients writing out the response. If writing responses block then there is the possibility that potentially slow clients could have an adverse effect on the distribution of the event. Example:
public class MyCometProcessor implements CometProcessor {
private List<Event> connections = new ArrayList<Event>();
public void onEvent(byte[] someInfo) {
synchronized (connections) {
for (Event e : connections) {
HttpServletResponse r = e.getHttpResponse();
// -- Does this line block while waiting for I/O --
r.getOutputStream().write(someInfo);
}
}
}
public void event(CometEvent event) {
switch (event.getEventType()) {
case READ:
synchronzied (connections) {
connections.add(event);
}
break;
// ...
}
}
}
Update: Answering my own question. Writes from a CometProcessor are blocking:
http://tomcat.apache.org/tomcat-6.0-doc/config/http.html
See the table at the bottom of the page.