boolean success = countdownLatch.await(configuration.getTimeout(), TimeUnit.MILLISECONDS);
if (!success) {
throw new ExchangeTimedOutException(exchange, configuration.getTimeout());
}
ClientChannelHandler handler = (ClientChannelHandler) clientPipeline.get("handler");
if (handler.getCause() != null) {
throw new CamelExchangeException("Error occurred in ClientChannelHandler", exchange, handler.getCause());
} else if (!handler.isMessageReceived()) {
// no message received
throw new CamelExchangeException("No response received from remote server: " + configuration.getAddress(), exchange);
} else {
// set the result on either IN or OUT on the original exchange depending on its pattern
if (ExchangeHelper.isOutCapable(exchange)) {
NettyPayloadHelper.setOut(exchange, handler.getMessage());
} else {
NettyPayloadHelper.setIn(exchange, handler.getMessage());
}
}
}
// should channel be closed after complete?