<div class="gmail_quote">On Fri, Mar 5, 2010 at 10:42 AM, infectedrhytms <span dir="ltr">&lt;<a href="mailto:infectedrhythms@hotmail.com">infectedrhythms@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
        private static final ChannelHandler stringDecoder = new StringDecoder();<br>
        private static final ChannelHandler stringEncoder = new StringEncoder();<br>
        //private static final ChannelHandler isoHandler = new MyHandler();<br>
<br>
        public ChannelPipeline getPipeline() throws Exception {<br>
<br>
                ChannelPipeline pipeline = Channels.pipeline();<br>
<br>
<br>
                pipeline.addLast(&quot;frameDecoder&quot;, new LengthFieldBasedFrameDecoder(1024, 0,<br>
2, 0, 2));<br>
                pipeline.addLast(&quot;decoder&quot;, stringDecoder);<br>
                pipeline.addLast(&quot;frameEncoder&quot;, new LengthFieldPrepender(2));<br>
                pipeline.addLast(&quot;encoder&quot;, stringEncoder);<br>
<br>
                pipeline.addLast(&quot;handler&quot;, new MyHandler()); // Calls JDBC stored<br>
procedure, business logic.<br>
<br>
                return pipeline;<br>
        }<br>
<br>
MyHandler does the logic and the stored procedure call. This doesn&#39;t take up<br>
any CPU time since the handler is waiting on the database to finish, but it<br>
shouldn&#39;t stall/queue other incoming requests.<br>
<font color="#888888"><br>
<br>
<br>
--<br>
View this message in context: <a href="http://n2.nabble.com/Long-running-handlers-tp4677280p4679153.html" target="_blank">http://n2.nabble.com/Long-running-handlers-tp4677280p4679153.html</a><br>
</font><div><div></div><div class="h5">Sent from the Netty User Group mailing list archive at Nabble.com.<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>
</div></div></blockquote></div><br><br><br>Hi,<br>
<br>
Putting a threadpool (for e.g. OrderedMemoryAwareThreadpoolExecutor) 
just before the final handler is a good idea that will unblock the i/o 
threads.<br>
<br>
Remember to share the instance of the Executors across all channels 
otherwise you will end up creating a lot of unnecessary threads.<br>
<br>
E.g.<br>
<br>
public class NioPipelineFactory implements ChannelPipelineFactory {<br>
    private OrderedMemoryAwareThreadPoolExecutor eventExecutors; <br>
<br>
   <br>
    public NioPipelineFactory(OrderedMemoryAwareThreadPoolExecutor 
eventExecutors )<br>
    {<br>
        this.eventExecutors=eventExecutors;<br>
    }<br>
    public ChannelPipeline getPipeline() throws Exception {<br>
        ChannelPipeline pipeline = Channels.pipeline();<br>
        pipeline.addLast(&quot;frameDecoder&quot;, new 
LengthFieldBasedFrameDecoder(1024, 0,<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> 2, 0, 
2));<br>
      pipeline.addLast(&quot;decoder&quot;, stringDecoder);<br>
      pipeline.addLast(&quot;frameEncoder&quot;, new 
LengthFieldPrepender(2));<br>
      pipeline.addLast(&quot;encoder&quot;, stringEncoder);<br></blockquote>
<div>        pipeline.addLast(&quot;Ordered&quot;, new 
ExecutionHandler(eventExecutors)); <br>
</div>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
     pipeline.addLast(&quot;handler&quot;, new MyHandler()); // Calls 
JDBC stored<br>
procedure, business logic.<br>
     return pipeline;</blockquote>
<br>
HTH,<br>
<br>
Thanks,<br>