<div class="gmail_quote">On Fri, Mar 5, 2010 at 10:42 AM, infectedrhytms <span dir="ltr"><<a href="mailto:infectedrhythms@hotmail.com">infectedrhythms@hotmail.com</a>></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("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0,<br>
2, 0, 2));<br>
pipeline.addLast("decoder", stringDecoder);<br>
pipeline.addLast("frameEncoder", new LengthFieldPrepender(2));<br>
pipeline.addLast("encoder", stringEncoder);<br>
<br>
pipeline.addLast("handler", 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't take up<br>
any CPU time since the handler is waiting on the database to finish, but it<br>
shouldn'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("frameDecoder", 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("decoder", stringDecoder);<br>
pipeline.addLast("frameEncoder", new
LengthFieldPrepender(2));<br>
pipeline.addLast("encoder", stringEncoder);<br></blockquote>
<div> pipeline.addLast("Ordered", 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("handler", new MyHandler()); // Calls
JDBC stored<br>
procedure, business logic.<br>
return pipeline;</blockquote>
<br>
HTH,<br>
<br>
Thanks,<br>