@Test public void testDispatchInOut() throws Exception { QName name = new QName("testDispatchInOut"); ExchangeSink inHandler = new ExchangeSink(true); ExchangeSink outHandler = new ExchangeSink(); Service service = new MockService(name, new InOutService(), inHandler); ServiceReference reference = new ServiceReferenceImpl(name, new InOutService(), null, null); Dispatcher dispatch = _provider.createDispatcher(reference); Exchange exchange = dispatch.createExchange(outHandler, ExchangePattern.IN_OUT); exchange.consumer(reference, reference.getInterface().getOperation(ServiceInterface.DEFAULT_OPERATION)); exchange.provider(service, service.getInterface().getOperation(ServiceInterface.DEFAULT_OPERATION)); Message message = exchange.createMessage(); exchange.send(message.setContent(REQUEST)); Thread.sleep(400); Exchange lastExchange = outHandler.getLastExchange(); assertNotNull(lastExchange); Property messageId = message.getContext().getProperty(Exchange.MESSAGE_ID); assertNotNull("Message id must be available after sending message and receiving response", messageId); Property relatesTo = lastExchange.getContext().getProperty(Exchange.RELATES_TO); assertNotNull("Relates to must be specified for outgoing message", relatesTo); assertEquals("Relates to property should point to in message id", messageId.getValue(), relatesTo.getValue()); }
@Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); }
ExchangeDispatcher implements Dispatcher { @Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); } }
ExchangeDispatcher implements Dispatcher { @Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); } ExchangeDispatcher(ModelCamelContext context, ServiceReference reference); }
ExchangeDispatcher implements Dispatcher { @Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); } ExchangeDispatcher(ModelCamelContext context, ServiceReference reference); @Override ServiceReference getServiceReference(); @Override Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern); @Override void dispatch(final Exchange exchange); }
ExchangeDispatcher implements Dispatcher { @Override public Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern) { DefaultExchange exchange = new DefaultExchange(_context, translate(pattern)); exchange.setIn(new CamelMessage(exchange)); return new CamelExchange(this, exchange, replyHandler); } ExchangeDispatcher(ModelCamelContext context, ServiceReference reference); @Override ServiceReference getServiceReference(); @Override Exchange createExchange(ExchangeHandler replyHandler, ExchangePattern pattern); @Override void dispatch(final Exchange exchange);  }