protected Message getAnswerMessage(final Exchange exchange) { Message answer = exchange.getIn(); if (ExchangeHelper.isOutCapable(exchange)) { answer = exchange.getOut(); // preserve headers answer.getHeaders().putAll(exchange.getIn().getHeaders()); } return answer; }
@Override public void doWithMessage(WebServiceMessage responseMessage) throws IOException, TransformerException { SoapMessage soapMessage = (SoapMessage) responseMessage; if (ExchangeHelper.isOutCapable(exchange)) { exchange.getOut().copyFromWithNewBody(exchange.getIn(), soapMessage.getPayloadSource()); populateHeaderAndAttachmentsFromResponse(exchange.getOut(), soapMessage); } else { exchange.getIn().setBody(soapMessage.getPayloadSource()); populateHeaderAndAttachmentsFromResponse(exchange.getIn(), soapMessage); } } });
@Override public void process(Exchange exchange) throws Exception { InputSource is = exchange.getIn().getMandatoryBody(InputSource.class); XMLStreamReader stream = exchange.getIn().getMandatoryBody(XMLStreamReader.class); XMLReader reader = new StaxStreamXMLReader(stream); ContentHandler handler; if (contentHandlerClass != null) { handler = contentHandlerClass.newInstance(); } else { handler = contentHandler; } reader.setContentHandler(handler); reader.parse(is); if (ExchangeHelper.isOutCapable(exchange)) { // preserve headers exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(handler); } else { exchange.getIn().setBody(handler); } }
@Override public void onComplete(Exchange exchange) { // should channel be closed after complete? Boolean close; if (ExchangeHelper.isOutCapable(exchange)) { close = exchange.getOut().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class); } else { close = exchange.getIn().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class); } // should we disconnect, the header can override the configuration boolean disconnect = getConfiguration().isDisconnect(); if (close != null) { disconnect = close; } if (disconnect) { LOG.trace("Closing channel {} as routing the Exchange is done", channel); NettyHelper.close(channel); } releaseChannel(channelFuture); } });
void finish(final Message result) { for (final Closeable closeable : closables) { IoUtils.safeClose(closeable); } if (result != null) { if (ExchangeHelper.isOutCapable(exchange)) { exchange.setOut(result); } else { exchange.setIn(result); } } callback.done(false); }
/** * 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 ctx the channel handler context * @param message 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, ChannelHandlerContext ctx, Object message) throws Exception { Object body = message; if (LOG.isDebugEnabled()) { LOG.debug("Channel: {} received body: {}", ctx.channel(), 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, message); } // 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(); } }
if (ExchangeHelper.isOutCapable(exchange)) { close = exchange.getOut().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class); } else {
/** * 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: {}", 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(); } }
if (ExchangeHelper.isOutCapable(exchange)) { close = exchange.getOut().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class); } else {
boolean isDelete = ZK_OPERATION_DELETE.equals(operation); if (ExchangeHelper.isOutCapable(exchange)) { if (isDelete) { if (log.isDebugEnabled()) {
if (ExchangeHelper.isOutCapable(exchange)) { exchange.setOut(message); } else { if (ExchangeHelper.isOutCapable(exchange)) { close = exchange.getOut().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class); } else {
|| (wait == WaitForTaskToComplete.IfReplyExpected && ExchangeHelper.isOutCapable(exchange))) {
if (ExchangeHelper.isOutCapable(exchange)) { exchange.setOut(result); } else {
if (ExchangeHelper.isOutCapable(exchange)) { exchange.setOut(message); } else { if (ExchangeHelper.isOutCapable(exchange)) { close = exchange.getOut().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class); } else {
|| (wait == WaitForTaskToComplete.IfReplyExpected && ExchangeHelper.isOutCapable(exchange))) {