Search in sources :

Example 1 with AbstractMessageListenerContainer

use of org.springframework.jms.listener.AbstractMessageListenerContainer in project camel by apache.

the class JmsConfiguration method createMessageListenerContainer.

public AbstractMessageListenerContainer createMessageListenerContainer(JmsEndpoint endpoint) throws Exception {
    AbstractMessageListenerContainer container = chooseMessageListenerContainerImplementation(endpoint);
    configureMessageListenerContainer(container, endpoint);
    return container;
}
Also used : AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer)

Example 2 with AbstractMessageListenerContainer

use of org.springframework.jms.listener.AbstractMessageListenerContainer in project camel by apache.

the class JmsEndpointConfigurationTest method testConfigureMessageListener.

@Test
public void testConfigureMessageListener() throws Exception {
    JmsEndpoint endpoint = resolveMandatoryEndpoint("jms:Foo.Bar?disableReplyTo=true&eagerLoadingOfProperties=true", JmsEndpoint.class);
    JmsConsumer consumer = endpoint.createConsumer(dummyProcessor);
    AbstractMessageListenerContainer container = consumer.getListenerContainer();
    Object object = container.getMessageListener();
    EndpointMessageListener messageListener = assertIsInstanceOf(EndpointMessageListener.class, object);
    assertTrue("Should have replyToDisabled", messageListener.isDisableReplyTo());
    assertTrue("Should have isEagerLoadingOfProperties()", messageListener.isEagerLoadingOfProperties());
}
Also used : AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 3 with AbstractMessageListenerContainer

use of org.springframework.jms.listener.AbstractMessageListenerContainer in project camel by apache.

the class JmsEndpointConfigurationTest method testSessionTransacted.

@Test
public void testSessionTransacted() throws Exception {
    JmsEndpoint endpoint = resolveMandatoryEndpoint("jms:queue:Foo?transacted=true&lazyCreateTransactionManager=false", JmsEndpoint.class);
    AbstractMessageListenerContainer container = endpoint.createConsumer(dummyProcessor).getListenerContainer();
    assertTrue("The JMS sessions will not be transactional!", container.isSessionTransacted());
    assertFalse("The transactionManager gets lazily generated!", endpoint.isLazyCreateTransactionManager());
    assertNull("The endpoint has an injected TransactionManager!", endpoint.getTransactionManager());
    endpoint = resolveMandatoryEndpoint("jms:queue:Foo?transacted=true", JmsEndpoint.class);
    container = endpoint.createConsumer(dummyProcessor).getListenerContainer();
    assertTrue("The JMS sessions will not be transactional!", container.isSessionTransacted());
    assertTrue("The transactionManager doesn't get lazily generated!", endpoint.isLazyCreateTransactionManager());
    assertNotNull("The endpoint has no injected TransactionManager!", endpoint.getTransactionManager());
}
Also used : AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 4 with AbstractMessageListenerContainer

use of org.springframework.jms.listener.AbstractMessageListenerContainer in project camel by apache.

the class JmsEndpointConfigurationTest method assertCacheLevel.

protected void assertCacheLevel(JmsEndpoint endpoint, int expected) throws Exception {
    JmsConsumer consumer = endpoint.createConsumer(dummyProcessor);
    AbstractMessageListenerContainer container = consumer.getListenerContainer();
    DefaultMessageListenerContainer defaultContainer = assertIsInstanceOf(DefaultMessageListenerContainer.class, container);
    int cacheLevel = defaultContainer.getCacheLevel();
    assertEquals("CacheLevel", expected, cacheLevel);
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer)

Example 5 with AbstractMessageListenerContainer

use of org.springframework.jms.listener.AbstractMessageListenerContainer in project camel by apache.

the class JmsEndpointConfigurationTest method assertDurableSubscriberEndpointIsValid.

protected void assertDurableSubscriberEndpointIsValid(JmsEndpoint endpoint) throws Exception {
    JmsConfiguration configuration = endpoint.getConfiguration();
    assertEquals("getDurableSubscriptionName()", "James", configuration.getDurableSubscriptionName());
    assertEquals("getClientId()", "ABC", configuration.getClientId());
    assertEquals("isDeliveryPersistent()", true, configuration.isDeliveryPersistent());
    JmsConsumer consumer = endpoint.createConsumer(new Processor() {

        public void process(Exchange exchange) throws Exception {
            log.info("Received: " + exchange);
        }
    });
    AbstractMessageListenerContainer listenerContainer = consumer.getListenerContainer();
    assertEquals("getDurableSubscriptionName()", "James", listenerContainer.getDurableSubscriptionName());
    assertEquals("getClientId()", "ABC", listenerContainer.getClientId());
    assertEquals("isSubscriptionDurable()", true, listenerContainer.isSubscriptionDurable());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) JMSException(javax.jms.JMSException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer)

Aggregations

AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)7 Test (org.junit.Test)4 JMSException (javax.jms.JMSException)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)1 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)1 SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)1