use of jakarta.jms.MessageListener 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);
assertThat(container.getActivationSpecConfig().getMaxConcurrency()).isEqualTo(10);
assertThat(container.getMessageListener()).isEqualTo(messageListener);
assertThat(container.getActivationSpecConfig().getDestinationName()).isEqualTo("myQueue");
}
use of jakarta.jms.MessageListener 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");
}
use of jakarta.jms.MessageListener in project spring-framework by spring-projects.
the class JmsNamespaceHandlerTests method testListeners.
@Test
public void testListeners() throws Exception {
TestBean testBean1 = context.getBean("testBean1", TestBean.class);
TestBean testBean2 = context.getBean("testBean2", TestBean.class);
TestMessageListener testBean3 = context.getBean("testBean3", TestMessageListener.class);
assertThat(testBean1.getName()).isNull();
assertThat(testBean2.getName()).isNull();
assertThat(testBean3.message).isNull();
TextMessage message1 = mock(TextMessage.class);
given(message1.getText()).willReturn("Test1");
MessageListener listener1 = getListener("listener1");
listener1.onMessage(message1);
assertThat(testBean1.getName()).isEqualTo("Test1");
TextMessage message2 = mock(TextMessage.class);
given(message2.getText()).willReturn("Test2");
MessageListener listener2 = getListener("listener2");
listener2.onMessage(message2);
assertThat(testBean2.getName()).isEqualTo("Test2");
TextMessage message3 = mock(TextMessage.class);
MessageListener listener3 = getListener(DefaultMessageListenerContainer.class.getName() + "#0");
listener3.onMessage(message3);
assertThat(testBean3.message).isSameAs(message3);
}
use of jakarta.jms.MessageListener in project spring-framework by spring-projects.
the class SimpleJmsListenerEndpoint method createMessageListener.
@Override
protected MessageListener createMessageListener(MessageListenerContainer container) {
MessageListener listener = getMessageListener();
Assert.state(listener != null, "No MessageListener set");
return listener;
}
Aggregations