Search in sources :

Example 11 with JMSConfiguration

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

the class JMSUtilTest method testJMSMessageMarshal.

@Test
public void testJMSMessageMarshal() throws IOException, JMSException {
    String testMsg = "Test Message";
    // TODO encoding
    final byte[] testBytes = testMsg.getBytes(Charset.defaultCharset().name());
    JMSConfiguration jmsConfig = new JMSConfiguration();
    jmsConfig.setConnectionFactory(new ActiveMQConnectionFactory("vm://tesstMarshal?broker.persistent=false"));
    try (ResourceCloser closer = new ResourceCloser()) {
        Connection connection = JMSFactory.createConnection(jmsConfig);
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        javax.jms.Message jmsMessage = JMSUtil.createAndSetPayload(testBytes, session, JMSConstants.BYTE_MESSAGE_TYPE);
        assertTrue("Message should have been of type BytesMessage ", jmsMessage instanceof BytesMessage);
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) Connection(javax.jms.Connection) BytesMessage(javax.jms.BytesMessage) Session(javax.jms.Session) Test(org.junit.Test)

Example 12 with JMSConfiguration

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

the class JMSClientServerTest method testReplyAndReplyToDestinations.

@Test(expected = SOAPFaultException.class)
public void testReplyAndReplyToDestinations() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setWsdlLocation("classpath:/wsdl/jms_test.wsdl");
    factory.setServiceName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService"));
    factory.setEndpointName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort"));
    factory.setAddress("jms://");
    JMSConfigFeature feature = new JMSConfigFeature();
    JMSConfiguration config = new JMSConfiguration();
    config.setConnectionFactory(new ActiveMQConnectionFactory(broker.getBrokerURL()));
    config.setRequestURI("test.jmstransport.text");
    config.setTargetDestination("test.jmstransport.text");
    // replyDestination and replyToDestination intentionally differ in this test scenario
    // replyDestination = Destination name to listen on for reply messages
    config.setReplyDestination("test.jmstransport.text.reply");
    // replyToDestination = Destination name to send out as replyTo address in the message
    config.setReplyToDestination("test.jmstransport.text.replyTo");
    config.setReceiveTimeout(1000L);
    feature.setJmsConfig(config);
    factory.getFeatures().add(feature);
    HelloWorldPortType greeter = factory.create(HelloWorldPortType.class);
    try {
        greeter.greetMe("FooBar");
    // Timeout exception should be thrown
    } finally {
        ((java.io.Closeable) greeter).close();
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConfigFeature(org.apache.cxf.transport.jms.JMSConfigFeature) QName(javax.xml.namespace.QName) Closeable(java.io.Closeable) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) Test(org.junit.Test)

Example 13 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(Endpoint endpoint) {
    if (!(endpoint instanceof EndpointImpl)) {
        return null;
    }
    final EndpointImpl ep = (EndpointImpl) endpoint;
    final QName serviceName = ep.getServiceName();
    if (serviceName == null) {
        return null;
    }
    final QName endpointName = ep.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) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl)

Example 14 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(Dispatch<?> dispatch) {
    if (!(dispatch instanceof DispatchImpl<?>)) {
        return null;
    }
    DispatchImpl<?> dsp = (DispatchImpl<?>) dispatch;
    Client cl = dsp.getClient();
    final QName serviceName;
    try {
        serviceName = cl.getEndpoint().getService().getName();
    } catch (Exception e) {
        if (LOGGER.isLoggable(Level.FINER)) {
            LOGGER.log(Level.FINER, "Exception caught: ", e);
        }
        return null;
    }
    if (serviceName == null) {
        return null;
    }
    QName endpointName;
    try {
        endpointName = cl.getEndpoint().getEndpointInfo().getName();
    } catch (Exception e) {
        if (LOGGER.isLoggable(Level.FINER)) {
            LOGGER.log(Level.FINER, "Exception caught: ", e);
        }
        endpointName = null;
    }
    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) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) QName(javax.xml.namespace.QName) Client(org.apache.cxf.endpoint.Client)

Example 15 with JMSConfiguration

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

the class DurableSubscriptionFeatureTest method testDurableSubscriptionFeature.

@Test
public void testDurableSubscriptionFeature() throws Exception {
    DurableSubscriptionFeature f = new DurableSubscriptionFeature();
    f.setDurableSubscriptionName("durableSubscriptionName");
    f.setDurableSubscriptionClientId("durableSubscriptionClientId");
    JMSConfiguration jmsConfig = new JMSConfiguration();
    JMSConduit conduit = createMock(JMSConduit.class);
    expect(conduit.getJmsConfig()).andReturn(jmsConfig).anyTimes();
    replay(conduit);
    Client client = createMock(Client.class);
    expect(client.getConduit()).andReturn(conduit).anyTimes();
    replay(client);
    Bus bus = createNiceMock(Bus.class);
    f.initialize(client, bus);
    assertSame("durableSubscriptionName", jmsConfig.getDurableSubscriptionName());
    assertSame("durableSubscriptionClientId", jmsConfig.getDurableSubscriptionClientId());
}
Also used : Bus(org.apache.cxf.Bus) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConduit(org.apache.cxf.transport.jms.JMSConduit) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

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