<div class="gmail_quote">On Tue, Dec 8, 2009 at 5:34 PM, Jay McGaffigan <span dir="ltr">&lt;<a href="mailto:hooligan495@gmail.com">hooligan495@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
...<br>
I guess my question is this... Does Netty have facilities in place<br>
already that facilitate the deferred response concept or should I<br>
expect that I will have to find a library elsewhere (or roll my own)<br>
to achieve this functionality on top of Netty?<br>
...<br></blockquote></div><br>Sure, that&#39;s possible. Netty make a great Comet server.<br>
<br>
If you&#39;d like to defer a response while waiting for a message to be sent, just don&#39;t close the connection.<br>
See the method writeReponse() in
<a href="http://anonsvn.jboss.org/repos/netty/trunk/src/main/java/org/jboss/netty/example/http/snoop/HttpRequestHandler.java">http://anonsvn.jboss.org/repos/netty/trunk/src/main/java/org/jboss/netty/example/http/snoop/HttpRequestHandler.java</a><br>

At the end the channel is closed. In the HTTP example, one channel is one request.<br>
You can skip the closing part and by doing that you keep the connection open.<br>
Of course, you need somewhere to keep track of your open requests
(channels) and dispatch message to all open connections when you
receive messages to send.<br>
<br>
By default, Netty spawns one I/O thread per processor to take advantage
of multi-core servers. As long as you don&#39;t do any synchronous I/O,
you&#39;ll be fine.<br>
<br>
--<br>
Carl<br>
<br>