<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">Thanks for your answer, Trustin.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>I was just wondering if there is a more generic way to handle this. IMHO when there is an institute of ExecutionHandler we should be able to shutdown it transparently (e.g. by signaling somewhere in the pipeline).<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Anyway, as far as I see, it should be handled now by this piece of code in "client" (to avoid pushing a referable instance of an Executor to the PipelineFactory):<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>         ExecutionHandler execHandler = (ExecutionHandler) channel.getPipeline().get("executor");<br>
         ExecutorService es = (ExecutorService) execHandler.getExecutor();<br>
         es.shutdown();<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Am I right?<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>TIA,<br>
Marian<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>On Tuesday 30 of December 2008 07:48:48 Trustin Lee wrote:<br>
> Hi Marian,<br>
><br>
> You need to shut down the OrderedMemoryAwareThreadPoolExecutor that<br>
> you've created by yourself. ChannelFactory.releaseExternalResources()<br>
> will not shut down the Executor that is used by ExecutionHandler.<br>
> Please call OrderedMemoryAwareThreadPoolExecutor.shutdown() after<br>
> calling ChannelFactory.releaseExternalResources(), then everything<br>
> should be cleaned up.<br>
><br>
> HTH,<br>
> Trustin<br>
><br>
> On Tue, Dec 30, 2008 at 2:09 AM, Marian Stranecky<br>
><br>
> <marian.stranecky@mobilbonus.cz> wrote:<br>
> > Hi all,<br>
> ><br>
> > I would like to ask you for information of how to connect and shutdown<br>
> > the client properly, because I have experienced a problem with netty<br>
> > while trying to use an ExecutionHandler:<br>
> > The threads created in OrderedMemoryAwareThreadPoolExecutor and used in<br>
> > handling are running even after the channel is closed (e.g. closed by a<br>
> > server after the channel is marked idle)<br>
> ><br>
> > Thanks in advance,<br>
> ><br>
> > Marian<br>
> ><br>
> > public ChannelPipeline getPipeline() throws Exception {<br>
> ><br>
> > ChannelPipeline pipeline = pipeline();<br>
> ><br>
> > // Add the number codec first,<br>
> > pipeline.addLast("decoder", new MyMessageDecoder());<br>
> > pipeline.addLast("encoder", new MyMessageEncoder());<br>
> ><br>
> > // utilize the processing<br>
> > // pipeline.addLast("executor", new ExecutionHandler(new<br>
> > OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));<br>
> ><br>
> ><br>
> > // and then business logic.<br>
> > pipeline.addLast("handler", new OISDClientHandler(this.client));<br>
> ><br>
> > return pipeline;<br>
> > }<br>
> ><br>
> ><br>
> > The client is as follows:<br>
> ><br>
> > public void connect(){<br>
> > ExecutorService bossExecutor = Executors.newCachedThreadPool(new<br>
> > CustomThreadFactory("bossExecutorPool"));<br>
> > ExecutorService workerExecutor = Executors.newCachedThreadPool(new<br>
> > CustomThreadFactory("workerExecutorPool"));<br>
> ><br>
> > ChannelFactory factory = new NioClientSocketChannelFactory(bossExecutor,<br>
> > workerExecutor);<br>
> ><br>
> > ClientBootstrap bootstrap = new ClientBootstrap(factory);<br>
> ><br>
> > bootstrap.setPipelineFactory(new OISDClientPipelineFactory(this));<br>
> ><br>
> > HashMap<String, Object> opts = new HashMap<String, Object>();<br>
> ><br>
> > opts.put("tcpNoDelay", false);<br>
> > opts.put("keepAlive", true);<br>
> ><br>
> > bootstrap.setOptions(opts);<br>
> ><br>
> > ChannelFuture connectFuture = bootstrap.connect(this.SMSCAddress);<br>
> ><br>
> > // Wait until the connection attempt succeeds or fails.<br>
> > this.channel = connectFuture.awaitUninterruptibly().getChannel();<br>
> ><br>
> > if (!connectFuture.isSuccess()) {<br>
> > log.error("Problem while connecting to " + this.SMSCAddress.toString(),<br>
> > connectFuture.getCause());<br>
> > return;<br>
> > }<br>
> ><br>
> > // Wait for the server to close the connection.<br>
> > channel.getCloseFuture().awaitUninterruptibly();<br>
> ><br>
> > // Shut down executor threads to exit.<br>
> > factory.releaseExternalResources();<br>
> > log.debug("resources released...");<br>
> > }<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > netty-users mailing list<br>
> > netty-users@lists.jboss.org<br>
> > https://lists.jboss.org/mailman/listinfo/netty-users<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p></body></html>