Proper way to handle async callbacks?
"이희승 (Trustin Lee)"
trustin at gmail.com
Mon Nov 8 23:48:44 EST 2010
kylar wrote:
> 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?
Not yet unfortunately. Feature planned in 4.0.
> #2) Do I need to have an additional set of threads to handle these requests
> without tying up the async clients?
Yes for now.
--
Trustin Lee - http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 290 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20101109/e9b202df/attachment.bin
More information about the netty-users
mailing list