use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-framework by spring-projects.
the class JmsNamespaceHandlerTests method testJmsContainerFactoryConfiguration.
@Test
public void testJmsContainerFactoryConfiguration() {
Map<String, DefaultJmsListenerContainerFactory> containers = context.getBeansOfType(DefaultJmsListenerContainerFactory.class);
DefaultJmsListenerContainerFactory factory = containers.get("testJmsFactory");
assertNotNull("No factory registered with testJmsFactory id", factory);
DefaultMessageListenerContainer container = factory.createListenerContainer(createDummyEndpoint());
assertEquals("explicit connection factory not set", context.getBean(EXPLICIT_CONNECTION_FACTORY), container.getConnectionFactory());
assertEquals("explicit destination resolver not set", context.getBean("testDestinationResolver"), container.getDestinationResolver());
assertEquals("explicit message converter not set", context.getBean("testMessageConverter"), container.getMessageConverter());
assertEquals("Wrong pub/sub", true, container.isPubSubDomain());
assertEquals("Wrong durable flag", true, container.isSubscriptionDurable());
assertEquals("wrong cache", DefaultMessageListenerContainer.CACHE_CONNECTION, container.getCacheLevel());
assertEquals("wrong concurrency", 3, container.getConcurrentConsumers());
assertEquals("wrong concurrency", 5, container.getMaxConcurrentConsumers());
assertEquals("wrong prefetch", 50, container.getMaxMessagesPerTask());
assertEquals("Wrong phase", 99, container.getPhase());
assertSame(context.getBean("testBackOff"), new DirectFieldAccessor(container).getPropertyValue("backOff"));
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testPubSubDomainActive.
@Test
public void testPubSubDomainActive() {
load(TestConfiguration.class, "spring.jms.pubSubDomain:true");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
DefaultMessageListenerContainer defaultMessageListenerContainer = this.context.getBean(DefaultJmsListenerContainerFactory.class).createListenerContainer(mock(JmsListenerEndpoint.class));
assertThat(jmsTemplate.isPubSubDomain()).isTrue();
assertThat(defaultMessageListenerContainer.isPubSubDomain()).isTrue();
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testDefaultContainerFactoryNonJtaTransactionManager.
@Test
public void testDefaultContainerFactoryNonJtaTransactionManager() {
this.context = createContext(TestConfiguration8.class, EnableJmsConfiguration.class);
JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("jmsListenerContainerFactory", JmsListenerContainerFactory.class);
assertThat(jmsListenerContainerFactory.getClass()).isEqualTo(DefaultJmsListenerContainerFactory.class);
DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory).createListenerContainer(mock(JmsListenerEndpoint.class));
assertThat(listenerContainer.isSessionTransacted()).isTrue();
assertThat(new DirectFieldAccessor(listenerContainer).getPropertyValue("transactionManager")).isNull();
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testCustomContainerFactoryWithConfigurer.
@Test
public void testCustomContainerFactoryWithConfigurer() {
this.context = doLoad(new Class<?>[] { TestConfiguration9.class, EnableJmsConfiguration.class }, "spring.jms.listener.autoStartup=false");
assertThat(this.context.containsBean("jmsListenerContainerFactory")).isTrue();
JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("customListenerContainerFactory", JmsListenerContainerFactory.class);
assertThat(jmsListenerContainerFactory).isInstanceOf(DefaultJmsListenerContainerFactory.class);
DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory).createListenerContainer(mock(JmsListenerEndpoint.class));
assertThat(listenerContainer.getCacheLevel()).isEqualTo(DefaultMessageListenerContainer.CACHE_CONSUMER);
assertThat(listenerContainer.isAutoStartup()).isFalse();
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project Protocol-Adapter-IEC61850 by OSGP.
the class MessagingConfig method iec61850RequestsMessageListenerContainer.
@Bean
public DefaultMessageListenerContainer iec61850RequestsMessageListenerContainer(final JmsConfiguration iec61850RequestJmsConfiguration) {
final DefaultMessageListenerContainer messageListenerContainer = iec61850RequestJmsConfiguration.getMessageListenerContainer();
messageListenerContainer.setErrorHandler(new ErrorHandler() {
@Override
public void handleError(final Throwable t) {
// Implementing ErrorHandler to prevent logging at WARN level
// when JMSException is thrown: Execution of JMS message
// listener failed, and no ErrorHandler has been set.
LOGGER.debug("iec61850RequestsMessageListenerContainer.ErrorHandler.handleError()", t);
}
});
return messageListenerContainer;
}
Aggregations