Bus bus = bf.createBus();
BusFactory.setDefaultBus(bus);
EndpointReferenceType target = new EndpointReferenceType();
connectionFactory = new PooledConnectionFactory(BROKER_URI);
TestReceiver receiver = new TestReceiver(connectionFactory, SERVICE_QUEUE, true);
receiver.runAsync();
JMSOldConfigHolder holder = new JMSOldConfigHolder();
EndpointInfo ei = new EndpointInfo();
String address = "jms:jndi:dynamicQueues/" + SERVICE_QUEUE
+ "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ "&replyToName=dynamicQueues/" + replyDestination
+ "&messageType=text"
+ "&jndiConnectionFactoryName=ConnectionFactory"
+ "&jndiURL=" + BROKER_URI;
ei.setAddress(address);
JMSConfiguration jmsConfig = holder.createJMSConfigurationFromEndpointInfo(bus, ei , null, true);
JMSConduit conduit = new JMSConduit(target, jmsConfig, bus);
Exchange exchange = new ExchangeImpl();
exchange.setSynchronous(synchronous);
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();
bus.shutdown(true);
}