Netty and HTTP asynchronous responses...

Carl Byström cgbystrom at gmail.com
Sat Dec 12 06:34:08 EST 2009


On Tue, Dec 8, 2009 at 5:34 PM, Jay McGaffigan <hooligan495 at gmail.com>wrote:

> ...
> I guess my question is this... Does Netty have facilities in place
> already that facilitate the deferred response concept or should I
> expect that I will have to find a library elsewhere (or roll my own)
> to achieve this functionality on top of Netty?
> ...
>

Sure, that's possible. Netty make a great Comet server.

If you'd like to defer a response while waiting for a message to be sent,
just don't close the connection.
See the method writeReponse() in
http://anonsvn.jboss.org/repos/netty/trunk/src/main/java/org/jboss/netty/example/http/snoop/HttpRequestHandler.java
At the end the channel is closed. In the HTTP example, one channel is one
request.
You can skip the closing part and by doing that you keep the connection
open.
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.

By default, Netty spawns one I/O thread per processor to take advantage of
multi-core servers. As long as you don't do any synchronous I/O, you'll be
fine.

--
Carl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20091212/70e6756b/attachment.html 


More information about the netty-users mailing list