use of org.apache.cxf.transport.jms.JMSConduit in project cxf by apache.
the class URIConfiguredConduitTest method sendAndReceive.
public void sendAndReceive(SyncType syncType, String address) throws Exception {
// Register bean locator for cf lookup
TestReceiver receiver = new TestReceiver(cf, SERVICE_QUEUE, false);
receiver.runAsync();
EndpointInfo ei = new EndpointInfo();
ei.setAddress(address);
Bus bus = BusFactory.getDefaultBus();
JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(bus, ei, null);
jmsConfig.setConnectionFactory(cf);
JMSConduit conduit = new JMSConduit(new EndpointReferenceType(), jmsConfig, bus);
Exchange exchange = new ExchangeImpl();
exchange.setSynchronous(syncType == SyncType.sync);
Message message = new MessageImpl();
exchange.setOutMessage(message);
conduit.sendExchange(exchange, "Request");
waitForAsyncReply(exchange);
receiver.close();
if (exchange.getInMessage() == null) {
throw new RuntimeException("No reply received within 2 seconds");
}
JMSMessageHeadersType inHeaders = (JMSMessageHeadersType) exchange.getInMessage().get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
Assert.assertEquals(receiver.getRequestMessageId(), inHeaders.getJMSCorrelationID());
conduit.close();
}
Aggregations