public void process(Exchange exchange) throws Exception { exchange.setPattern( ExchangePattern.InOut ); Message inMessage = exchange.getIn(); inMessage.setHeader( CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE ); inMessage.setHeader( Exchange.HTTP_METHOD, "POST" ); inMessage.setHeader( Exchange.HTTP_PATH, "/execute" ); inMessage.setHeader( Exchange.ACCEPT_CONTENT_TYPE, "text/plain" ); inMessage.setHeader( Exchange.CONTENT_TYPE, "text/plain" ); } }
public void process(Exchange exchange) throws Exception { exchange.setPattern( ExchangePattern.InOut ); Message inMessage = exchange.getIn(); inMessage.setHeader( CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE ); inMessage.setHeader( Exchange.HTTP_METHOD, "POST" ); inMessage.setHeader( Exchange.HTTP_PATH, "/execute" ); inMessage.setHeader( Exchange.ACCEPT_CONTENT_TYPE, "text/plain" ); inMessage.setHeader( Exchange.CONTENT_TYPE, "text/plain" ); } }
public static Exchange convertToExchange(CamelContext context, Object data) { Exchange exchange; if (data instanceof Exchange) { exchange = (Exchange) data; } else { exchange = new DefaultExchange(context); exchange.setPattern(ExchangePattern.InOut); exchange.getIn().setBody(data); } return exchange; }
public void process(Exchange exchange) throws Exception { exchange.setPattern( ExchangePattern.InOut ); Message inMessage = exchange.getIn(); inMessage.setHeader( CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE ); inMessage.setHeader( Exchange.HTTP_METHOD, "POST" ); inMessage.setHeader( Exchange.HTTP_PATH, "/execute" ); inMessage.setHeader( Exchange.ACCEPT_CONTENT_TYPE, "text/plain" ); inMessage.setHeader( Exchange.CONTENT_TYPE, "text/plain" ); this.processor.process( exchange ); }
public void process(Exchange exchange) throws Exception { exchange.setPattern( ExchangePattern.InOut ); Message inMessage = exchange.getIn(); inMessage.setHeader( CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE ); inMessage.setHeader( Exchange.HTTP_METHOD, "POST" ); inMessage.setHeader( Exchange.HTTP_PATH, "/execute" ); inMessage.setHeader( Exchange.ACCEPT_CONTENT_TYPE, "text/plain" ); inMessage.setHeader( Exchange.CONTENT_TYPE, "text/plain" ); this.processor.process( exchange ); }
public void process(Exchange exchange) throws Exception { exchange.setPattern( ExchangePattern.InOut ); BindingOperationInfo boi = (BindingOperationInfo) exchange.getProperty( BindingOperationInfo.class.toString() ); if ( boi != null ) { LOG.info( "boi.isUnwrapped" + boi.isUnwrapped() ); } SOAPMessage soapMessage = (SOAPMessage) exchange.getIn().getBody(); exchange.getOut().setBody( soapMessage.getSOAPBody().getTextContent() ); } }
public void process(Exchange exchange) throws Exception { exchange.setPattern( ExchangePattern.InOut ); BindingOperationInfo boi = (BindingOperationInfo) exchange.getProperty( BindingOperationInfo.class.toString() ); if ( boi != null ) { LOG.info( "boi.isUnwrapped" + boi.isUnwrapped() ); } SOAPMessage soapMessage = (SOAPMessage) exchange.getIn().getBody(); exchange.getOut().setBody( soapMessage.getSOAPBody().getTextContent() ); } }
@Override public OrchestratedTestSpecification build(int partCount, OrchestratedTestSpecification nextPart) { addRepeatedProcessor(exchange -> exchange.setPattern(ExchangePattern.InOut)); return super.build(partCount, nextPart); } }
public synchronized void sendInOnlyMessage(Map properties, Map headers, Object body, String endpoint){ Exchange exchange = new DefaultExchange(getCamelContext()); exchange.setPattern(ExchangePattern.InOnly); Endpoint ep = getCamelContext().getEndpoint(endpoint); if (properties!=null){ if(properties.containsKey("methodName")) exchange.setProperty("methodName", properties.get("methodName")); if (properties.containsKey("protocol")) exchange.setProperty("protocol",properties.get("protocol")); } if (headers!=null) exchange.getIn().setHeaders(headers); exchange.getIn().setBody(body); producerTemplate.send(ep, exchange); if (exchange.getException() != null){ logger.warn("caught exception while sending jms message", exchange.getException()); } } @Override
private ZooKeeperEndpoint createCandidateNode(CamelContext camelContext) { LOG.info("Initializing ZookeeperElection with uri '{}'", uri); ZooKeeperEndpoint zep = camelContext.getEndpoint(uri, ZooKeeperEndpoint.class); zep.getConfiguration().setCreate(true); String fullpath = createFullPathToCandidate(zep); Exchange e = zep.createExchange(); e.setPattern(ExchangePattern.InOut); e.getIn().setHeader(ZooKeeperMessage.ZOOKEEPER_NODE, fullpath); e.getIn().setHeader(ZooKeeperMessage.ZOOKEEPER_CREATE_MODE, CreateMode.EPHEMERAL_SEQUENTIAL); producerTemplate.send(zep, e); if (e.isFailed()) { LOG.warn("Error setting up election node {}", fullpath, e.getException()); } else { LOG.info("Candidate node '{}' has been created", fullpath); try { camelContext.addRoutes(new ElectoralMonitorRoute(zep)); } catch (Exception ex) { LOG.warn("Error configuring ZookeeperElection", ex); } } return zep; }
exchange.setPattern(ExchangePattern.InOut); final SettableFuture<T> result = SettableFuture.create(); logger.debug("sending inout message");
exchange.setPattern(ExchangePattern.InOut); Exchange send = producerTemplate.send(endpointUri, exchange); return send.getIn().getBody();
/** * Converts outgoing request to a {@link Message} * and performs some exchange configuration. */ @Override public void process(Exchange exchange) throws Exception { if (charsetName != null) { exchange.setProperty(Exchange.CHARSET_NAME, charsetName); } Message msg = Hl7v2MarshalUtils.extractHapiMessage( exchange.getIn(), characterSet(exchange), getEndpoint().getHl7v2TransactionConfiguration().getParser()); if (msg == null) { throw new Hl7v2AdaptingException("Cannot create HL7v2 message from the given " + ClassUtils.getSimpleName(exchange.getIn().getBody(), "<null>")); } exchange.getIn().setBody(msg); exchange.setPattern(ExchangePattern.InOut); // run the route getWrappedProcessor().process(exchange); } }
public Exchange createExchange(MessageExchange exchange) { Exchange result = new DefaultExchange(context); result.setProperty(MESSAGE_EXCHANGE, exchange); result.setPattern(getExchangePattern(exchange)); if (exchange.getOperation() != null) { result.setProperty(OPERATION, exchange.getOperation()); } if (exchange.getMessage("in") != null) { copyFromJbiToCamel(exchange.getMessage("in"), result.getIn()); } copyPropertiesFromJbiToCamel(exchange, result); return result; }
public Exchange createExchange(Message message, Session session, Object replyDestination) { Exchange exchange = endpoint.createExchange(); JmsBinding binding = getBinding(); exchange.setProperty(Exchange.BINDING, binding); exchange.setIn(new JmsMessage(message, session, binding)); // lets set to an InOut if we have some kind of reply-to destination if (replyDestination != null && !disableReplyTo) { // only change pattern if not already out capable if (!exchange.getPattern().isOutCapable()) { exchange.setPattern(ExchangePattern.InOut); } } return exchange; }
camelExchange.setPattern(ExchangePattern.InOnly); camelExchange.setPattern(ExchangePattern.InOnly);
exchange.setPattern((replyToUri == null) ? ExchangePattern.InOut : ExchangePattern.InOnly);
@Override protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { Object in = msg; if (LOG.isDebugEnabled()) { LOG.debug("Channel: {} received body: {}", ctx.channel(), in); } // create Exchange and let the consumer process it final Exchange exchange = consumer.getEndpoint().createExchange(ctx, msg); if (consumer.getConfiguration().isSync()) { exchange.setPattern(ExchangePattern.InOut); } // set the exchange charset property for converting if (consumer.getConfiguration().getCharsetName() != null) { exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(consumer.getConfiguration().getCharsetName())); } if (consumer.getConfiguration().isReuseChannel()) { exchange.setProperty(NettyConstants.NETTY_CHANNEL, ctx.channel()); } // we want to handle the UoW consumer.createUoW(exchange); beforeProcess(exchange, ctx, msg); // process accordingly to endpoint configuration if (consumer.getEndpoint().isSynchronous()) { processSynchronously(exchange, ctx, msg); } else { processAsynchronously(exchange, ctx, msg); } }
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent messageEvent) throws Exception { Object in = messageEvent.getMessage(); if (LOG.isDebugEnabled()) { LOG.debug("Channel: {} received body: {}", messageEvent.getChannel(), in); } // create Exchange and let the consumer process it final Exchange exchange = consumer.getEndpoint().createExchange(ctx, messageEvent); if (consumer.getConfiguration().isSync()) { exchange.setPattern(ExchangePattern.InOut); } // set the exchange charset property for converting if (consumer.getConfiguration().getCharsetName() != null) { exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(consumer.getConfiguration().getCharsetName())); } // we want to handle the UoW consumer.createUoW(exchange); beforeProcess(exchange, messageEvent); // process accordingly to endpoint configuration if (consumer.getEndpoint().isSynchronous()) { processSynchronously(exchange, messageEvent); } else { processAsynchronously(exchange, messageEvent); } }
@Override public void onMessage(HazelcastMQMessage msg) { String replyToDestination = msg.getReplyTo(); String correlationId = msg.getCorrelationId(); // Build an exchange. Message camelMsg = messageConverter.toCamelMessage(msg); Exchange camelExchange = getEndpoint().createExchange(); // Change the pattern to out/in if we have a reply destination // and the exchange isn't already out capable. if (replyToDestination != null && !camelExchange.getPattern(). isOutCapable()) { camelExchange.setPattern(ExchangePattern.OutIn); } camelExchange.setIn(camelMsg); try { getProcessor().process(camelExchange); } catch (Throwable e) { camelExchange.setException(e); } if (!camelExchange.isFailed() && replyToDestination != null && camelExchange.getPattern().isOutCapable()) { sendReply(correlationId, replyToDestination, camelExchange); } if (camelExchange.isFailed()) { getExceptionHandler().handleException("Error processing exchange.", camelExchange, camelExchange.getException()); } }