<div class="gmail_quote">On Thu, Dec 10, 2009 at 6:08 PM, drofa <span dir="ltr">&lt;<a href="mailto:drofa@yahoo.com">drofa@yahoo.com</a>&gt;</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;">
<br>
I&#39;m new to Netty, and I need some help, Netty is async by nature but right<br>
now I need to process some client to server requests in synchronous way.. so<br>
after call to server I method is blocked until server response arrives or<br>
failed by timeout.. I would appreciate any code example . Thanks in advance<br><br></blockquote></div><br>You need to make sure you put your handler after an ExecutionHandler. By doing that, processing will be deferred to worker threads, decoupled from the main I/O loop.<br>
The main I/O has by default X threads, where X is number of processors. If you block that, you will block the server&#39;s ability to process I/O.<br>It&#39;s recommended to only put CPU-bound code here (such as protocol encoding/decoding) and defer handlers that do blocking I/O to worker threads behind an ExecutionHandler.<br>
<br>See <a href="http://www.jboss.org/community/wiki/NettyExampleofPingPongusingObject">http://www.jboss.org/community/wiki/NettyExampleofPingPongusingObject</a> and the PongPipelineFactory class. You&#39;ll see in the getPipeline() method how a pipeline executor gets inserted. OrderedMemoryAwareThreadPoolExecutor is probably what you want.<br>
<br>--<br>Carl <br>