Search in sources :

Example 31 with CachingConnectionFactory

use of org.springframework.jms.connection.CachingConnectionFactory in project spring-boot by spring-projects.

the class ArtemisAutoConfigurationTests method connectionFactoryCachingCanBeCustomized.

@Test
void connectionFactoryCachingCanBeCustomized() {
    this.contextRunner.withUserConfiguration(EmptyConfiguration.class).withPropertyValues("spring.jms.cache.consumers=true", "spring.jms.cache.producers=false", "spring.jms.cache.session-cache-size=10").run((context) -> {
        assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(CachingConnectionFactory.class).hasBean("jmsConnectionFactory");
        CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
        assertThat(context.getBean("jmsConnectionFactory")).isSameAs(connectionFactory);
        assertThat(connectionFactory.isCacheConsumers()).isTrue();
        assertThat(connectionFactory.isCacheProducers()).isFalse();
        assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(10);
    });
}
Also used : CachingConnectionFactory(org.springframework.jms.connection.CachingConnectionFactory) Test(org.junit.jupiter.api.Test)

Example 32 with CachingConnectionFactory

use of org.springframework.jms.connection.CachingConnectionFactory in project spring-boot by spring-projects.

the class ArtemisAutoConfigurationTests method connectionFactoryIsCachedByDefault.

@Test
void connectionFactoryIsCachedByDefault() {
    this.contextRunner.withUserConfiguration(EmptyConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(CachingConnectionFactory.class).hasBean("jmsConnectionFactory");
        CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
        assertThat(context.getBean("jmsConnectionFactory")).isSameAs(connectionFactory);
        assertThat(connectionFactory.getTargetConnectionFactory()).isInstanceOf(ActiveMQConnectionFactory.class);
        assertThat(connectionFactory.isCacheConsumers()).isFalse();
        assertThat(connectionFactory.isCacheProducers()).isTrue();
        assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1);
    });
}
Also used : CachingConnectionFactory(org.springframework.jms.connection.CachingConnectionFactory) Test(org.junit.jupiter.api.Test)

Aggregations

CachingConnectionFactory (org.springframework.jms.connection.CachingConnectionFactory)32 Test (org.junit.Test)21 JmsTemplate (org.springframework.jms.core.JmsTemplate)20 TextMessage (javax.jms.TextMessage)15 Message (javax.jms.Message)11 GenericMessage (org.springframework.messaging.support.GenericMessage)11 MessageCreator (org.springframework.jms.core.MessageCreator)10 BeanFactory (org.springframework.beans.factory.BeanFactory)9 Destination (javax.jms.Destination)8 ComponentLog (org.apache.nifi.logging.ComponentLog)7 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)6 JmsChannelFactoryBean (org.springframework.integration.jms.config.JmsChannelFactoryBean)6 ConnectionFactory (javax.jms.ConnectionFactory)5 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)5 ArrayList (java.util.ArrayList)4 ExecutorService (java.util.concurrent.ExecutorService)4 Session (javax.jms.Session)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 Executors (java.util.concurrent.Executors)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3