Search in sources :

Example 1 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project camel by apache.

the class JmsConfiguration method configureMessageListener.

public void configureMessageListener(EndpointMessageListener listener) {
    if (isDisableReplyTo()) {
        listener.setDisableReplyTo(true);
    }
    if (isEagerLoadingOfProperties()) {
        listener.setEagerLoadingOfProperties(true);
    }
    if (getReplyTo() != null) {
        listener.setReplyToDestination(getReplyTo());
    }
    JmsOperations operations = listener.getTemplate();
    if (operations instanceof JmsTemplate) {
        JmsTemplate template = (JmsTemplate) operations;
        template.setDeliveryPersistent(isReplyToDeliveryPersistent());
    }
}
Also used : JmsTemplate(org.springframework.jms.core.JmsTemplate) JmsOperations(org.springframework.jms.core.JmsOperations)

Example 2 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project camel by apache.

the class ConsumeJmsMapMessageTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    jmsTemplate = new JmsTemplate(connectionFactory);
    camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) ConnectionFactory(javax.jms.ConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate)

Example 3 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project camel by apache.

the class ConsumeJmsObjectMessageTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    jmsTemplate = new JmsTemplate(connectionFactory);
    camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) ConnectionFactory(javax.jms.ConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate)

Example 4 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project camel by apache.

the class ConsumeJmsBytesMessageTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    jmsTemplate = new JmsTemplate(connectionFactory);
    camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) ConnectionFactory(javax.jms.ConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate)

Example 5 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project camel by apache.

the class JmsEndpointConfigurationTest method testReplyToPesistentDelivery.

@Test
public void testReplyToPesistentDelivery() throws Exception {
    JmsEndpoint endpoint = resolveMandatoryEndpoint("jms:queue:Foo", JmsEndpoint.class);
    endpoint.getConfiguration().setDeliveryPersistent(true);
    endpoint.getConfiguration().setReplyToDeliveryPersistent(false);
    Producer producer = endpoint.createProducer();
    assertNotNull("The producer should not be null", producer);
    JmsConsumer consumer = endpoint.createConsumer(dummyProcessor);
    JmsOperations operations = consumer.getEndpointMessageListener().getTemplate();
    assertTrue(operations instanceof JmsTemplate);
    JmsTemplate template = (JmsTemplate) operations;
    assertTrue("Wrong delivery mode on reply template; expected  " + " DeliveryMode.NON_PERSISTENT but was DeliveryMode.PERSISTENT", template.getDeliveryMode() == DeliveryMode.NON_PERSISTENT);
}
Also used : Producer(org.apache.camel.Producer) JmsTemplate(org.springframework.jms.core.JmsTemplate) JmsOperations(org.springframework.jms.core.JmsOperations) Test(org.junit.Test)

Aggregations

JmsTemplate (org.springframework.jms.core.JmsTemplate)45 Test (org.junit.Test)30 ConnectionFactory (javax.jms.ConnectionFactory)12 Session (javax.jms.Session)9 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)8 Connection (javax.jms.Connection)7 TransactionStatus (org.springframework.transaction.TransactionStatus)7 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)7 Bean (org.springframework.context.annotation.Bean)5 Destination (javax.jms.Destination)4 TextMessage (javax.jms.TextMessage)4 CamelContext (org.apache.camel.CamelContext)4 SessionCallback (org.springframework.jms.core.SessionCallback)4 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)4 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)4 JMSException (javax.jms.JMSException)3 Message (javax.jms.Message)3 PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)3 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3 JmsOperations (org.springframework.jms.core.JmsOperations)3