Search in sources :

Example 21 with JmsTemplate

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

the class JmsAutoConfigurationTests method testActiveMQOverriddenPoolAndStandalone.

@Test
public void testActiveMQOverriddenPoolAndStandalone() {
    load(TestConfiguration.class, "spring.activemq.pool.enabled:true", "spring.activemq.inMemory:false");
    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(ACTIVEMQ_NETWORK_URL);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) Test(org.junit.Test)

Example 22 with JmsTemplate

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

the class JmsAutoConfigurationTests method testActiveMQOverriddenStandalone.

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

Example 23 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project opennms by OpenNMS.

the class AppConfig method jmsTemplate.

//
// JMS Template
//
@Bean(name = "JmsTemplate")
public JmsTemplate jmsTemplate() {
    JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory());
    jmsTemplate.setExplicitQosEnabled(true);
    jmsTemplate.setTimeToLive(120000);
    return jmsTemplate;
}
Also used : JmsTemplate(org.springframework.jms.core.JmsTemplate) Bean(org.springframework.context.annotation.Bean)

Example 24 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project av-service by dvoraka.

the class JmsFileCommonConfig method jmsTemplate.

@Bean
public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory, MessageConverter messageConverter) {
    JmsTemplate template = new JmsTemplate(connectionFactory);
    template.setReceiveTimeout(receiveTimeout);
    template.setMessageConverter(messageConverter);
    return template;
}
Also used : JmsTemplate(org.springframework.jms.core.JmsTemplate) Bean(org.springframework.context.annotation.Bean)

Example 25 with JmsTemplate

use of org.springframework.jms.core.JmsTemplate in project camel by apache.

the class JmsAnotherCustomJMSReplyToTest method testCustomJMSReplyToInOnly.

@Test
public void testCustomJMSReplyToInOnly() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("My name is Arnio");
    // start a inOnly route
    template.sendBody("activemq:queue:hello", "Hello, I'm here");
    // now consume using something that is not Camel
    Thread.sleep(1000);
    JmsTemplate jms = new JmsTemplate(amq.getConfiguration().getConnectionFactory());
    TextMessage msg = (TextMessage) jms.receive("nameRequestor");
    assertEquals("What's your name", msg.getText());
    // there should be a JMSReplyTo so we know where to send the reply
    Destination replyTo = msg.getJMSReplyTo();
    assertEquals("queue://nameReplyQueue", replyTo.toString());
    // send reply
    template.sendBody("activemq:" + replyTo.toString(), "My name is Arnio");
    Thread.sleep(2000);
    assertMockEndpointsSatisfied();
}
Also used : Destination(javax.jms.Destination) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) JmsTemplate(org.springframework.jms.core.JmsTemplate) TextMessage(javax.jms.TextMessage) 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