Search in sources :

Example 1 with DefaultJmsListenerContainerFactory

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;
}
Also used : DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with DefaultJmsListenerContainerFactory

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();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 3 with DefaultJmsListenerContainerFactory

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();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) Test(org.junit.Test)

Example 4 with DefaultJmsListenerContainerFactory

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);
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) Test(org.junit.Test)

Example 5 with DefaultJmsListenerContainerFactory

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"));
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) Test(org.junit.Test)

Aggregations

DefaultJmsListenerContainerFactory (org.springframework.jms.config.DefaultJmsListenerContainerFactory)7 Test (org.junit.Test)6 JmsListenerEndpoint (org.springframework.jms.config.JmsListenerEndpoint)6 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)6 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 JtaTransactionManager (org.springframework.transaction.jta.JtaTransactionManager)1