if (LOG.isTraceEnabled()) {
LOG.trace("Pool[active={}, idle={}]", pool.getNumActive(), pool.getNumIdle());
}
// get a channel from the pool
Channel existing;
try {
existing = pool.borrowObject();
if (existing != null) {
LOG.trace("Got channel from pool {}", existing);
}
} catch (Exception e) {
exchange.setException(e);
callback.done(true);
return true;
}
// we must have a channel
if (existing == null) {
exchange.setException(new CamelExchangeException("Cannot get channel from pool", exchange));
callback.done(true);
return true;
}
// need to declare as final
final Channel channel = existing;
final AsyncCallback producerCallback = new NettyProducerCallback(channel, callback);
// setup state as attachment on the channel, so we can access the state later when needed
channel.setAttachment(new NettyCamelState(producerCallback, exchange));
// write body
NettyHelper.writeBodyAsync(LOG, channel, null, body, exchange, new ChannelFutureListener() {
public void operationComplete(ChannelFuture channelFuture) throws Exception {
LOG.trace("Operation complete {}", channelFuture);