Search in sources :

Example 16 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.

the class JmsAutoConfigurationTests method testPubSubDomainOverride.

@Test
public void testPubSubDomainOverride() {
    load(TestConfiguration.class, "spring.jms.pubSubDomain:false");
    JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
    ActiveMQConnectionFactory connectionFactory = this.context.getBean(ActiveMQConnectionFactory.class);
    assertThat(jmsTemplate).isNotNull();
    assertThat(jmsTemplate.isPubSubDomain()).isFalse();
    assertThat(connectionFactory).isNotNull();
    assertThat(connectionFactory).isEqualTo(jmsTemplate.getConnectionFactory());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Example 17 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.

the class JmsAutoConfigurationTests method testActiveMQOverriddenPoolAndRemoteServer.

@Test
public void testActiveMQOverriddenPoolAndRemoteServer() {
    load(TestConfiguration.class, "spring.activemq.pool.enabled:true", "spring.activemq.brokerUrl:tcp://remote-host:10000");
    JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
    PooledConnectionFactory pool = this.context.getBean(PooledConnectionFactory.class);
    assertThat(jmsTemplate).isNotNull();
    assertThat(pool).isNotNull();
    assertThat(pool).isEqualTo(jmsTemplate.getConnectionFactory());
    ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) pool.getConnectionFactory();
    assertThat(factory.getBrokerURL()).isEqualTo("tcp://remote-host:10000");
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) Test(org.junit.Test)

Example 18 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.

the class JmsAutoConfigurationTests method testJmsTemplateBackOff.

@Test
public void testJmsTemplateBackOff() {
    load(TestConfiguration3.class);
    JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
    assertThat(jmsTemplate.getPriority()).isEqualTo(999);
}
Also used : JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Example 19 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.

the class JmsAutoConfigurationTests method testDefaultJmsConfiguration.

@Test
public void testDefaultJmsConfiguration() {
    load(TestConfiguration.class);
    ActiveMQConnectionFactory connectionFactory = this.context.getBean(ActiveMQConnectionFactory.class);
    JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
    JmsMessagingTemplate messagingTemplate = this.context.getBean(JmsMessagingTemplate.class);
    assertThat(connectionFactory).isEqualTo(jmsTemplate.getConnectionFactory());
    assertThat(messagingTemplate.getJmsTemplate()).isEqualTo(jmsTemplate);
    assertThat(((ActiveMQConnectionFactory) jmsTemplate.getConnectionFactory()).getBrokerURL()).isEqualTo(ACTIVEMQ_EMBEDDED_URL);
    assertThat(this.context.containsBean("jmsListenerContainerFactory")).isTrue();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JmsMessagingTemplate(org.springframework.jms.core.JmsMessagingTemplate) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Example 20 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.

the class JmsAutoConfigurationTests method testJmsTemplatePostProcessedSoThatPubSubIsTrue.

@Test
public void testJmsTemplatePostProcessedSoThatPubSubIsTrue() {
    load(TestConfiguration4.class);
    JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
    assertThat(jmsTemplate.isPubSubDomain()).isTrue();
}
Also used : JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Aggregations

JmsTemplate (org.springframework.jms.core.JmsTemplate)45 Test (org.junit.Test)30 ConnectionFactory (javax.jms.ConnectionFactory)12 Session (javax.jms.Session)9 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)8 Connection (javax.jms.Connection)7 TransactionStatus (org.springframework.transaction.TransactionStatus)7 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)7 Bean (org.springframework.context.annotation.Bean)5 Destination (javax.jms.Destination)4 TextMessage (javax.jms.TextMessage)4 CamelContext (org.apache.camel.CamelContext)4 SessionCallback (org.springframework.jms.core.SessionCallback)4 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)4 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)4 JMSException (javax.jms.JMSException)3 Message (javax.jms.Message)3 PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)3 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3 JmsOperations (org.springframework.jms.core.JmsOperations)3