Search in sources :

Example 16 with SimpleMessageListenerContainer

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

the class MethodJmsListenerEndpointTests method processAndReplyWithSendToQueue.

@Test
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(this.sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.jupiter.api.Test)

Example 17 with SimpleMessageListenerContainer

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

the class MethodJmsListenerEndpointTests method processAndReplyWithSendToTopic.

@Test
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(this.sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.jupiter.api.Test)

Example 18 with SimpleMessageListenerContainer

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

the class MethodJmsListenerEndpointTests method processAndReplyWithCustomReplyQosSettings.

@Test
void processAndReplyWithCustomReplyQosSettings() throws JMSException {
    String methodName = "processAndReplyWithSendTo";
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    QosSettings replyQosSettings = new QosSettings(1, 6, 6000);
    container.setReplyQosSettings(replyQosSettings);
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
    processAndReplyWithSendTo(listener, "replyDestination", false, replyQosSettings);
    assertListenerMethodInvocation(this.sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) QosSettings(org.springframework.jms.support.QosSettings) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.jupiter.api.Test)

Example 19 with SimpleMessageListenerContainer

use of org.springframework.jms.listener.SimpleMessageListenerContainer 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);
    assertThat(container.getMessageListener()).isEqualTo(messageListener);
    assertThat(container.getDestinationName()).isEqualTo("myQueue");
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) MessageListener(jakarta.jms.MessageListener) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.jupiter.api.Test)

Example 20 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}
 */
protected void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException {
    JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class);
    assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1);
    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(jakarta.jms.Session)

Aggregations

SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)20 Test (org.junit.jupiter.api.Test)9 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)7 Bean (org.springframework.context.annotation.Bean)6 MessageListener (jakarta.jms.MessageListener)2 Test (org.junit.Test)2 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)2 MethodJmsListenerEndpoint (org.springframework.jms.config.MethodJmsListenerEndpoint)2 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)2 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)2 MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)2 Session (jakarta.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 QosSettings (org.springframework.jms.support.QosSettings)1