Search in sources :

Example 1 with JMSConduit

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();
}
Also used : Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Bus(org.apache.cxf.Bus) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) Message(org.apache.cxf.message.Message) JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) TestReceiver(org.apache.cxf.transport.jms.util.TestReceiver) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Aggregations

Bus (org.apache.cxf.Bus)1 Exchange (org.apache.cxf.message.Exchange)1 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)1 Message (org.apache.cxf.message.Message)1 MessageImpl (org.apache.cxf.message.MessageImpl)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 JMSConduit (org.apache.cxf.transport.jms.JMSConduit)1 JMSConfiguration (org.apache.cxf.transport.jms.JMSConfiguration)1 JMSMessageHeadersType (org.apache.cxf.transport.jms.JMSMessageHeadersType)1 TestReceiver (org.apache.cxf.transport.jms.util.TestReceiver)1 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)1