ExecutionHandler problem
Marian Stranecky
marian.stranecky at mobilbonus.cz
Mon Dec 29 12:09:45 EST 2008
Hi all,
I would like to ask you for information of how to connect and shutdown the client properly, because I have experienced a problem with netty while trying to use an ExecutionHandler:
The threads created in OrderedMemoryAwareThreadPoolExecutor and used in handling are running even after the channel is closed (e.g. closed by a server after the channel is marked idle)
Thanks in advance,
Marian
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
// Add the number codec first,
pipeline.addLast("decoder", new MyMessageDecoder());
pipeline.addLast("encoder", new MyMessageEncoder());
// utilize the processing
// pipeline.addLast("executor", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
// and then business logic.
pipeline.addLast("handler", new OISDClientHandler(this.client));
return pipeline;
}
The client is as follows:
public void connect(){
ExecutorService bossExecutor = Executors.newCachedThreadPool(new CustomThreadFactory("bossExecutorPool"));
ExecutorService workerExecutor = Executors.newCachedThreadPool(new CustomThreadFactory("workerExecutorPool"));
ChannelFactory factory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor);
ClientBootstrap bootstrap = new ClientBootstrap(factory);
bootstrap.setPipelineFactory(new OISDClientPipelineFactory(this));
HashMap<String, Object> opts = new HashMap<String, Object>();
opts.put("tcpNoDelay", false);
opts.put("keepAlive", true);
bootstrap.setOptions(opts);
ChannelFuture connectFuture = bootstrap.connect(this.SMSCAddress);
// Wait until the connection attempt succeeds or fails.
this.channel = connectFuture.awaitUninterruptibly().getChannel();
if (!connectFuture.isSuccess()) {
log.error("Problem while connecting to " + this.SMSCAddress.toString(), connectFuture.getCause());
return;
}
// Wait for the server to close the connection.
channel.getCloseFuture().awaitUninterruptibly();
// Shut down executor threads to exit.
factory.releaseExternalResources();
log.debug("resources released...");
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20081229/a669de5a/attachment.html
More information about the netty-users
mailing list