use of org.jboss.netty.channel.group.ChannelGroupFuture in project camel by apache.
the class NettyProducer method doStop.
@Override
protected void doStop() throws Exception {
LOG.debug("Stopping producer at address: {}", configuration.getAddress());
// close all channels
LOG.trace("Closing {} channels", allChannels.size());
ChannelGroupFuture future = allChannels.close();
future.awaitUninterruptibly();
// and then shutdown the thread pools
if (bossPool != null) {
bossPool.shutdown();
bossPool = null;
}
if (workerPool != null) {
if (workerPool instanceof ExternalResourceReleasable) {
// this will first invoke workerPool#shutdown() internally (e.g. org.jboss.netty.channel.socket.nio.AbstractNioWorkerPool)
((ExternalResourceReleasable) workerPool).releaseExternalResources();
} else {
workerPool.shutdown();
}
workerPool = null;
}
if (pool != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Stopping producer with channel pool[active={}, idle={}]", pool.getNumActive(), pool.getNumIdle());
}
pool.close();
pool = null;
}
if (channelFactory != null) {
// this will first invoke channelFactory#shutdown() internally (see it's javadoc)
channelFactory.releaseExternalResources();
channelFactory = null;
}
if (datagramChannelFactory != null) {
// this will first invoke datagramChannelFactory#shutdown() internally (see it's javadoc)
datagramChannelFactory.releaseExternalResources();
datagramChannelFactory = null;
}
super.doStop();
}
Aggregations