Search in sources :

Example 11 with SimpleMessageListenerContainer

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

the class MethodJmsListenerEndpointTests method processAndReplyWithSendToTopic.

@Test
public void processAndReplyWithSendToTopic() throws JMSException {
    String methodName = "processAndReplyWithSendTo";
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setPubSubDomain(true);
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
    processAndReplyWithSendTo(listener, "replyDestination", true);
    assertListenerMethodInvocation(sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.Test)

Example 12 with SimpleMessageListenerContainer

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

the class MethodJmsListenerEndpointTests method processAndReplyWithSendToQueue.

@Test
public void processAndReplyWithSendToQueue() throws JMSException {
    String methodName = "processAndReplyWithSendTo";
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
    processAndReplyWithSendTo(listener, "replyDestination", false);
    assertListenerMethodInvocation(sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.Test)

Example 13 with SimpleMessageListenerContainer

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

the class AbstractJmsAnnotationDrivenTests method testJmsHandlerMethodFactoryConfiguration.

/**
	 * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified
	 * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}.
	 *
	 * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException}
	 */
public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException {
    JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class);
    assertEquals(1, simpleFactory.getListenerContainers().size());
    MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint();
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    endpoint.setupListenerContainer(container);
    MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener();
    listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class));
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) StubTextMessage(org.springframework.jms.StubTextMessage) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) JmsListenerContainerTestFactory(org.springframework.jms.config.JmsListenerContainerTestFactory) MethodJmsListenerEndpoint(org.springframework.jms.config.MethodJmsListenerEndpoint) Session(javax.jms.Session)

Aggregations

SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)13 Test (org.junit.Test)8 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)5 Bean (org.springframework.context.annotation.Bean)3 MessageListener (javax.jms.MessageListener)2 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)2 MethodJmsListenerEndpoint (org.springframework.jms.config.MethodJmsListenerEndpoint)2 MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)2 Session (javax.jms.Session)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 StubTextMessage (org.springframework.jms.StubTextMessage)1 AbstractJmsListenerEndpoint (org.springframework.jms.config.AbstractJmsListenerEndpoint)1 JmsListenerEndpoint (org.springframework.jms.config.JmsListenerEndpoint)1 MessageListenerTestContainer (org.springframework.jms.config.MessageListenerTestContainer)1 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)1 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)1 ErrorHandler (org.springframework.util.ErrorHandler)1