NettyProducer.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:Camel 作者:
@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();

    // release the external resource here and we keep the timer open
    // 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();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号