Search in sources :

Example 1 with MessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessageListenerAdapter in project spring-framework by spring-projects.

the class JmsListenerContainerFactoryTests method createJmsContainerFullConfig.

@Test
public void createJmsContainerFullConfig() {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    setDefaultJmsConfig(factory);
    factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
    factory.setConcurrency("3-10");
    factory.setMaxMessagesPerTask(5);
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);
    assertDefaultJmsConfig(container);
    assertEquals(DefaultMessageListenerContainer.CACHE_CONSUMER, container.getCacheLevel());
    assertEquals(3, container.getConcurrentConsumers());
    assertEquals(10, container.getMaxConcurrentConsumers());
    assertEquals(5, container.getMaxMessagesPerTask());
    assertEquals(messageListener, container.getMessageListener());
    assertEquals("myQueue", container.getDestinationName());
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) MessageListener(javax.jms.MessageListener) Test(org.junit.Test)

Example 2 with MessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessageListenerAdapter in project spring-framework by spring-projects.

the class JmsListenerContainerFactoryTests method jcaExclusiveProperties.

@Test
public void jcaExclusiveProperties() {
    DefaultJcaListenerContainerFactory factory = new DefaultJcaListenerContainerFactory();
    factory.setDestinationResolver(destinationResolver);
    factory.setActivationSpecFactory(new StubJmsActivationSpecFactory());
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setMessageListener(new MessageListenerAdapter());
    thrown.expect(IllegalStateException.class);
    factory.createListenerContainer(endpoint);
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) StubJmsActivationSpecFactory(org.springframework.jms.listener.endpoint.StubJmsActivationSpecFactory) Test(org.junit.Test)

Example 3 with MessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessageListenerAdapter in project spring-framework by spring-projects.

the class SimpleJmsListenerEndpointTests method createListener.

@Test
public void createListener() {
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    assertSame(messageListener, endpoint.createMessageListener(container));
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) MessageListener(javax.jms.MessageListener) Test(org.junit.Test)

Example 4 with MessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessageListenerAdapter in project spring-framework by spring-projects.

the class JmsListenerEndpointTests method setupJmsMessageContainerFullConfig.

@Test
public void setupJmsMessageContainerFullConfig() {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    MessageListener messageListener = new MessageListenerAdapter();
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setDestination("myQueue");
    endpoint.setSelector("foo = 'bar'");
    endpoint.setSubscription("mySubscription");
    endpoint.setConcurrency("5-10");
    endpoint.setMessageListener(messageListener);
    endpoint.setupListenerContainer(container);
    assertEquals("myQueue", container.getDestinationName());
    assertEquals("foo = 'bar'", container.getMessageSelector());
    assertEquals("mySubscription", container.getSubscriptionName());
    assertEquals(5, container.getConcurrentConsumers());
    assertEquals(10, container.getMaxConcurrentConsumers());
    assertEquals(messageListener, container.getMessageListener());
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) MessageListener(javax.jms.MessageListener) Test(org.junit.Test)

Example 5 with MessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessageListenerAdapter in project spring-framework by spring-projects.

the class JmsListenerEndpointTests method setupConcurrencySimpleContainer.

@Test
public void setupConcurrencySimpleContainer() {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    MessageListener messageListener = new MessageListenerAdapter();
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    // simple implementation only support max value
    endpoint.setConcurrency("5-10");
    endpoint.setMessageListener(messageListener);
    endpoint.setupListenerContainer(container);
    assertEquals(10, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers"));
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) MessageListener(javax.jms.MessageListener) Test(org.junit.Test)

Aggregations

MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)12 Test (org.junit.Test)11 MessageListener (javax.jms.MessageListener)8 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)4 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)3 JmsMessageEndpointManager (org.springframework.jms.listener.endpoint.JmsMessageEndpointManager)3 MessageListenerContainer (org.springframework.jms.listener.MessageListenerContainer)1 JmsActivationSpecConfig (org.springframework.jms.listener.endpoint.JmsActivationSpecConfig)1 StubJmsActivationSpecFactory (org.springframework.jms.listener.endpoint.StubJmsActivationSpecFactory)1 BackOff (org.springframework.util.backoff.BackOff)1 FixedBackOff (org.springframework.util.backoff.FixedBackOff)1