Search in sources :

Example 1 with JMSConfiguration

use of org.apache.cxf.transport.jms.JMSConfiguration in project cxf by apache.

the class SOAPJMSTestSuiteTest method twoWayTestWithCreateMessage.

public void twoWayTestWithCreateMessage(final TestCaseType testcase) throws Exception {
    String address = testcase.getAddress();
    EndpointInfo endpointInfo = new EndpointInfo();
    endpointInfo.setAddress(JMSTestUtil.getFullAddress(address, broker.getBrokerURL()));
    JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(staticBus, endpointInfo, null);
    ResourceCloser closer = new ResourceCloser();
    try {
        Connection connection = closer.register(JMSFactory.createConnection(jmsConfig));
        connection.start();
        Session session = closer.register(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
        Destination targetDest = jmsConfig.getTargetDestination(session);
        Destination replyToDestination = jmsConfig.getReplyToDestination(session, null);
        JMSSender sender = JMSFactory.createJmsSender(jmsConfig, null);
        Message jmsMessage = JMSTestUtil.buildJMSMessageFromTestCase(testcase, session, replyToDestination);
        sender.sendMessage(session, targetDest, jmsMessage);
        Message replyMessage = JMSUtil.receive(session, replyToDestination, jmsMessage.getJMSMessageID(), 10000, true);
        checkReplyMessage(replyMessage, testcase);
    } catch (JMSException e) {
        throw JMSUtil.convertJmsException(e);
    } finally {
        closer.close();
    }
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(javax.jms.Destination) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) Message(javax.jms.Message) Connection(javax.jms.Connection) ResourceCloser(org.apache.cxf.transport.jms.util.ResourceCloser) JMSSender(org.apache.cxf.transport.jms.util.JMSSender) JMSException(javax.jms.JMSException) Session(javax.jms.Session)

Example 2 with JMSConfiguration

use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.

the class JmsConfiguratorTest method testCreateAndConfigureEndpoint.

@Test
public void testCreateAndConfigureEndpoint() {
    HelloWorldImpl2 implementor = new HelloWorldImpl2();
    String address = "local://JmsUriConfiguratorTest";
    ep = Endpoint.publish(address, implementor);
    JmsConfigurator jmsConfigurator = JmsConfigurator.create(ep);
    Assert.assertNotNull(jmsConfigurator);
    Assert.assertEquals("HelloWorldImpl2Port", jmsConfigurator.getConfigurationPrefix());
    Assert.assertEquals(SERVICE_NAME, jmsConfigurator.getServiceName());
    JMSConfiguration jmsConf = new JMSConfiguration();
    jmsConfigurator.setJmsConfiguration(jmsConf);
    Endpoint ep2 = jmsConfigurator.configureEndpoint(ep);
    Assert.assertNotNull(ep2);
    Configuration cnf = jmsConfigurator.getConfiguration();
    Assert.assertNotNull(cnf);
    Assert.assertEquals("org.apache.activemq.jndi.ActiveMQInitialContextFactory", cnf.get("jndiInitialContextFactory"));
    Assert.assertEquals("jndi", cnf.get("variant"));
    Assert.assertEquals("ConnectionFactory", cnf.get("jndiConnectionFactoryName"));
    Assert.assertEquals("tcp://localhost:61616", cnf.get("jndiURL"));
    Assert.assertEquals("dynamicQueues/libraryprovider.queue", cnf.get("destinationName"));
    List<Feature> features = ((EndpointImpl) ep2).getFeatures();
    boolean jmsConfigFeaturePresent = false;
    for (Feature f : features) {
        if (f instanceof org.apache.cxf.transport.jms.JMSConfigFeature) {
            jmsConfigFeaturePresent = true;
            break;
        }
    }
    Assert.assertTrue(jmsConfigFeaturePresent);
}
Also used : JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) Configuration(org.talend.esb.mep.requestcallback.feature.Configuration) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) Feature(org.apache.cxf.feature.Feature) HelloWorldImpl2(org.talend.esb.mep.requestcallback.test.internal.HelloWorldImpl2) JmsConfigurator(org.talend.esb.mep.requestcallback.beans.JmsConfigurator) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 3 with JMSConfiguration

use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.

the class JmsConfiguratorTest method createAndConfigureDispatchAddressing.

@Test
public void createAndConfigureDispatchAddressing() {
    Service service = Service.create(SERVICE_NAME);
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "jms://");
    Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    Assert.assertNotNull(dispatch);
    JmsConfigurator jmsConfigurator = JmsConfigurator.create(dispatch);
    Assert.assertNotNull(jmsConfigurator);
    Assert.assertEquals("SoapPort", jmsConfigurator.getConfigurationPrefix());
    Assert.assertEquals(SERVICE_NAME, jmsConfigurator.getServiceName());
    Dispatch<Source> dispatch2 = jmsConfigurator.configureDispatch(dispatch, "jms://");
    Assert.assertNotNull(dispatch2);
    Conduit conduit = ((DispatchImpl) dispatch2).getClient().getConduit();
    Assert.assertNotNull(conduit);
    Assert.assertTrue(conduit instanceof JMSConduit);
    JMSConduit jmsConduit = (JMSConduit) conduit;
    JMSConfiguration jmsConfiguration = jmsConduit.getJmsConfig();
    Assert.assertNotNull(jmsConfiguration);
}
Also used : JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) Conduit(org.apache.cxf.transport.Conduit) Service(javax.xml.ws.Service) Source(javax.xml.transform.Source) JmsConfigurator(org.talend.esb.mep.requestcallback.beans.JmsConfigurator) Test(org.junit.Test)

Example 4 with JMSConfiguration

use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.

the class JmsConfiguratorTest method createAndConfigureDispatch.

@Test
public void createAndConfigureDispatch() {
    Service service = Service.create(SERVICE_NAME);
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "jms://");
    Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    Assert.assertNotNull(dispatch);
    JmsConfigurator jmsConfigurator = JmsConfigurator.create(dispatch);
    Assert.assertNotNull(jmsConfigurator);
    Assert.assertEquals("SoapPort", jmsConfigurator.getConfigurationPrefix());
    Assert.assertEquals(SERVICE_NAME, jmsConfigurator.getServiceName());
    Dispatch<Source> dispatch2 = jmsConfigurator.configureDispatch(dispatch);
    Assert.assertNotNull(dispatch2);
    Conduit conduit = ((DispatchImpl) dispatch2).getClient().getConduit();
    Assert.assertNotNull(conduit);
    Assert.assertTrue(conduit instanceof JMSConduit);
    JMSConduit jmsConduit = (JMSConduit) conduit;
    JMSConfiguration jmsConfiguration = jmsConduit.getJmsConfig();
    Assert.assertNotNull(jmsConfiguration);
}
Also used : JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) Conduit(org.apache.cxf.transport.Conduit) Service(javax.xml.ws.Service) Source(javax.xml.transform.Source) JmsConfigurator(org.talend.esb.mep.requestcallback.beans.JmsConfigurator) Test(org.junit.Test)

Example 5 with JMSConfiguration

use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.

the class JmsConfigurator method create.

public static JmsConfigurator create(JaxWsServerFactoryBean factory) {
    if (factory == null) {
        return null;
    }
    final QName serviceName = factory.getServiceName();
    if (serviceName == null) {
        return null;
    }
    final QName endpointName = factory.getEndpointName();
    final String portName = endpointName == null ? null : endpointName.getLocalPart();
    JmsConfigurator result = new JmsConfigurator();
    result.setConfigurationPrefix(portName);
    result.setJmsConfiguration(new JMSConfiguration());
    result.setServiceName(serviceName);
    return result;
}
Also used : JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) QName(javax.xml.namespace.QName)

Aggregations

JMSConfiguration (org.apache.cxf.transport.jms.JMSConfiguration)17 JMSConduit (org.apache.cxf.transport.jms.JMSConduit)7 Test (org.junit.Test)7 QName (javax.xml.namespace.QName)4 Properties (java.util.Properties)3 Bus (org.apache.cxf.Bus)3 Conduit (org.apache.cxf.transport.Conduit)3 JmsConfigurator (org.talend.esb.mep.requestcallback.beans.JmsConfigurator)3 Connection (javax.jms.Connection)2 Session (javax.jms.Session)2 Source (javax.xml.transform.Source)2 Service (javax.xml.ws.Service)2 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)2 Client (org.apache.cxf.endpoint.Client)2 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 JMSDestination (org.apache.cxf.transport.jms.JMSDestination)2 Configuration (org.talend.esb.mep.requestcallback.feature.Configuration)2 Closeable (java.io.Closeable)1 BytesMessage (javax.jms.BytesMessage)1