use of org.springframework.jms.config.DefaultJmsListenerContainerFactory in project spring-boot by spring-projects.
the class JmsAnnotationDrivenConfiguration method jmsListenerContainerFactory.
@Bean
@ConditionalOnMissingBean(name = "jmsListenerContainerFactory")
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(DefaultJmsListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
configurer.configure(factory, connectionFactory);
return factory;
}
use of org.springframework.jms.config.DefaultJmsListenerContainerFactory 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.config.DefaultJmsListenerContainerFactory 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.config.DefaultJmsListenerContainerFactory in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testJmsListenerContainerFactoryWithCustomSettings.
@Test
public void testJmsListenerContainerFactoryWithCustomSettings() {
load(EnableJmsConfiguration.class, "spring.jms.listener.autoStartup=false", "spring.jms.listener.acknowledgeMode=client", "spring.jms.listener.concurrency=2", "spring.jms.listener.maxConcurrency=10");
JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("jmsListenerContainerFactory", JmsListenerContainerFactory.class);
assertThat(jmsListenerContainerFactory.getClass()).isEqualTo(DefaultJmsListenerContainerFactory.class);
DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory).createListenerContainer(mock(JmsListenerEndpoint.class));
assertThat(listenerContainer.isAutoStartup()).isFalse();
assertThat(listenerContainer.getSessionAcknowledgeMode()).isEqualTo(Session.CLIENT_ACKNOWLEDGE);
assertThat(listenerContainer.getConcurrentConsumers()).isEqualTo(2);
assertThat(listenerContainer.getMaxConcurrentConsumers()).isEqualTo(10);
}
use of org.springframework.jms.config.DefaultJmsListenerContainerFactory in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testDefaultContainerFactoryWithMessageConverters.
@Test
public void testDefaultContainerFactoryWithMessageConverters() {
this.context = createContext(MessageConvertersConfiguration.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.getMessageConverter()).isSameAs(this.context.getBean("myMessageConverter"));
}
Aggregations