views:

69

answers:

0

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 ChannelPipeline:

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 to. 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, and have it executed by a Netty thread? or... 2) Do I need to have an additional set of threads to handle these requests without tying up the async clients?