Yes, thanks, its clear now. I think this deserves a mention in the docs, otherwise its too mysterious.<br><br>Utkarsh<br><br><div class="gmail_quote">On Tue, Mar 10, 2009 at 3:11 PM, Trustin Lee <span dir="ltr"><<a href="mailto:tlee@redhat.com">tlee@redhat.com</a>></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;"><div><div></div><div class="h5">On Wed, Mar 11, 2009 at 6:30 AM, Utkarsh Srivastava <<a href="mailto:utkarsh@gmail.com">utkarsh@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I am a day old to netty and still finding my way around. Looks like a really<br>
> slick framework!<br>
><br>
> I am having a little trouble understanding the handler pipeline (yes, I have<br>
> read the api docs for ChannelPipeline, ChannelHandler and ChannelEvent). To<br>
> take a concrete example, the server pipeline in the example time server has<br>
> the following pipeline:<br>
><br>
> ChannelPipeline p = pipeline();<br>
> 1. p.addLast("frameDecoder", new<br>
> LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4));<br>
> 2. p.addLast("protobufDecoder", new<br>
> ProtobufDecoder(LocalTimeProtocol.Locations.getDefaultInstance()));<br>
><br>
> 3. p.addLast("frameEncoder", new LengthFieldPrepender(4));<br>
> 4. p.addLast("protobufEncoder", new ProtobufEncoder());<br>
><br>
> 5. p.addLast("handler", new LocalTimeServerHandler());<br>
> return p;<br>
><br>
> For a given request, handlers are executed in the order 1,2,5,4,3, right?<br>
> Thats the only order that makes sense.<br>
><br>
> But thats totally different from the order they are added to the pipeline in<br>
> the code.<br>
<br>
</div></div>That's a good question. When an event goes upstream, the order is 1,<br>
2, 3, 4, 5. When an event goes downstream, the order is 5, 4, 3, 2,<br>
1. However, ChannelPipline does some trick to shorten the stack<br>
depth.<br>
<br>
3 and 4 don't implement ChannelUpstreamHandler, and therefore the<br>
actual evaluation order of an upstream event will be: 1, 2, and 5.<br>
<br>
1, 2, and 5 don't implement ChannelDownstreamHandler, and therefore<br>
the actual evaluation order of a downstream event will be: 4 and 3<br>
<br>
If 5 extends SimpleChannelHandler, it means 5 implements both<br>
ChannelUpstreamHandler and ChannelDownstreamHandler. Therefore the<br>
evaluation order for upstream and downstream events will be 125 and<br>
543.<br>
<br>
Sounds clear? :)<br>
<br>
HTH,<br>
Trustin<br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</blockquote></div><br>