Search in sources :

Example 6 with MessageListenerAdapter

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

the class JmsListenerEndpointTests method setupMessageContainerUnsupportedContainer.

@Test
public void setupMessageContainerUnsupportedContainer() {
    MessageListenerContainer container = mock(MessageListenerContainer.class);
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setMessageListener(new MessageListenerAdapter());
    thrown.expect(IllegalArgumentException.class);
    endpoint.setupListenerContainer(container);
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) MessageListenerContainer(org.springframework.jms.listener.MessageListenerContainer) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.Test)

Example 7 with MessageListenerAdapter

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

the class JmsListenerEndpointTests method setupJcaMessageContainerFullConfig.

@Test
public void setupJcaMessageContainerFullConfig() {
    JmsMessageEndpointManager container = new JmsMessageEndpointManager();
    MessageListener messageListener = new MessageListenerAdapter();
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setDestination("myQueue");
    endpoint.setSelector("foo = 'bar'");
    endpoint.setSubscription("mySubscription");
    endpoint.setConcurrency("10");
    endpoint.setMessageListener(messageListener);
    endpoint.setupListenerContainer(container);
    JmsActivationSpecConfig config = container.getActivationSpecConfig();
    assertEquals("myQueue", config.getDestinationName());
    assertEquals("foo = 'bar'", config.getMessageSelector());
    assertEquals("mySubscription", config.getSubscriptionName());
    assertEquals(10, config.getMaxConcurrency());
    assertEquals(messageListener, container.getMessageListener());
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) JmsMessageEndpointManager(org.springframework.jms.listener.endpoint.JmsMessageEndpointManager) MessageListener(javax.jms.MessageListener) JmsActivationSpecConfig(org.springframework.jms.listener.endpoint.JmsActivationSpecConfig) Test(org.junit.Test)

Example 8 with MessageListenerAdapter

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

the class JmsListenerContainerFactoryTests method createJcaContainerFullConfig.

@Test
public void createJcaContainerFullConfig() {
    DefaultJcaListenerContainerFactory factory = new DefaultJcaListenerContainerFactory();
    setDefaultJcaConfig(factory);
    factory.setConcurrency("10");
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    JmsMessageEndpointManager container = factory.createListenerContainer(endpoint);
    assertDefaultJcaConfig(container);
    assertEquals(10, container.getActivationSpecConfig().getMaxConcurrency());
    assertEquals(messageListener, container.getMessageListener());
    assertEquals("myQueue", container.getActivationSpecConfig().getDestinationName());
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) JmsMessageEndpointManager(org.springframework.jms.listener.endpoint.JmsMessageEndpointManager) MessageListener(javax.jms.MessageListener) Test(org.junit.Test)

Example 9 with MessageListenerAdapter

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

the class JmsListenerContainerFactoryTests method backOffOverridesRecoveryInterval.

@Test
public void backOffOverridesRecoveryInterval() {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    BackOff backOff = new FixedBackOff();
    factory.setBackOff(backOff);
    factory.setRecoveryInterval(2000L);
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);
    assertSame(backOff, new DirectFieldAccessor(container).getPropertyValue("backOff"));
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) MessageListener(javax.jms.MessageListener) FixedBackOff(org.springframework.util.backoff.FixedBackOff) BackOff(org.springframework.util.backoff.BackOff) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.Test)

Example 10 with MessageListenerAdapter

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

the class JmsListenerContainerFactoryTests method createSimpleContainer.

@Test
public void createSimpleContainer() {
    SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
    setDefaultJmsConfig(factory);
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    SimpleMessageListenerContainer container = factory.createListenerContainer(endpoint);
    assertDefaultJmsConfig(container);
    assertEquals(messageListener, container.getMessageListener());
    assertEquals("myQueue", container.getDestinationName());
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) MessageListener(javax.jms.MessageListener) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) 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