/** * Gets the Camel {@link Message} to use as the message to be set on the current {@link Exchange} * when we have received a reply message. * * <p> * * @param exchange the current exchange * @param messageEvent the incoming event which has the response message from Netty. * @return the Camel {@link Message} to set on the current {@link Exchange} as the response * message. * @throws Exception is thrown if error getting the response message */ protected Message getResponseMessage(Exchange exchange, MessageEvent messageEvent) throws Exception { Object body = messageEvent.getMessage(); if (LOG.isDebugEnabled()) { LOG.debug("Channel: {} received body: {}", new Object[] {messageEvent.getChannel(), body}); } // if textline enabled then covert to a String which must be used for textline if (producer.getConfiguration().isTextline()) { body = producer.getContext().getTypeConverter().mandatoryConvertTo(String.class, exchange, body); } // set the result on either IN or OUT on the original exchange depending on its pattern if (ExchangeHelper.isOutCapable(exchange)) { NettyPayloadHelper.setOut(exchange, body); return exchange.getOut(); } else { NettyPayloadHelper.setIn(exchange, body); return exchange.getIn(); } }