Proper way to handle async callbacks?
kylar
kylar42 at gmail.com
Wed Aug 4 14:00:58 EDT 2010
Here's my scenario: I've got a custom protocol built on HTTP. I've started a
netty server that has two custom handlers after the http ones in the
pipeline:
pipeline.addLast("decoder", new HttpRequestDecoder(1024, 10240,
32768));
pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("authenticator", new AuthenticationHandler());
pipeline.addLast("handler", new MyProtocolServiceHandler());
in AuthenticationHandler (a SimpleChannelUpstreamHandler) 's
messageRecieved, I check to see if the user has an Authentication: header,
and if so, I call out to an external authentication service, using an
asynchronous client (a com.ning.http.client.AsyncHttpClient), which I pass a
callback too. When the authentication request returns, I want to pass the
ChannelHandlerContext and original HttpMessage on to the next handler. Right
now, I'm just calling
Channels.fireMessageReceived(context, result, remoteAddress);
- But I think this is getting executed by the AsyncHttpClient 's thread
instead of one of the Netty container's threads.
So my questions are:
#1) Is there a way to throw this request back into the proper pool?
#2) Do I need to have an additional set of threads to handle these requests
without tying up the async clients?
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Proper-way-to-handle-async-callbacks-tp5373639p5373639.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list