use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.
the class ArtemisAutoConfigurationTests method embeddedWithPersistentMode.
@Test
public void embeddedWithPersistentMode() throws IOException, JMSException {
File dataFolder = this.folder.newFolder();
// Start the server and post a message to some queue
load(EmptyConfiguration.class, "spring.artemis.embedded.queues=TestQueue", "spring.artemis.embedded.persistent:true", "spring.artemis.embedded.dataDirectory:" + dataFolder.getAbsolutePath());
final String msgId = UUID.randomUUID().toString();
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
jmsTemplate.send("TestQueue", new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(msgId);
}
});
// Shutdown the broker
this.context.close();
// Start the server again and check if our message is still here
load(EmptyConfiguration.class, "spring.artemis.embedded.queues=TestQueue", "spring.artemis.embedded.persistent:true", "spring.artemis.embedded.dataDirectory:" + dataFolder.getAbsolutePath());
JmsTemplate jmsTemplate2 = this.context.getBean(JmsTemplate.class);
jmsTemplate2.setReceiveTimeout(1000L);
Message message = jmsTemplate2.receive("TestQueue");
assertThat(message).isNotNull();
assertThat(((TextMessage) message).getText()).isEqualTo(msgId);
}
use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.
the class ArtemisAutoConfigurationTests method nativeConnectionFactory.
@Test
public void nativeConnectionFactory() {
load(EmptyConfiguration.class, "spring.artemis.mode:native");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
ActiveMQConnectionFactory connectionFactory = this.context.getBean(ActiveMQConnectionFactory.class);
assertThat(connectionFactory).isEqualTo(jmsTemplate.getConnectionFactory());
assertNettyConnectionFactory(connectionFactory, "localhost", 61616);
assertThat(connectionFactory.getUser()).isNull();
assertThat(connectionFactory.getPassword()).isNull();
}
use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testActiveMQOverriddenPool.
@Test
public void testActiveMQOverriddenPool() {
load(TestConfiguration.class, "spring.activemq.pool.enabled:true");
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_EMBEDDED_URL);
}
use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testPubSubDomainActive.
@Test
public void testPubSubDomainActive() {
load(TestConfiguration.class, "spring.jms.pubSubDomain:true");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
DefaultMessageListenerContainer defaultMessageListenerContainer = this.context.getBean(DefaultJmsListenerContainerFactory.class).createListenerContainer(mock(JmsListenerEndpoint.class));
assertThat(jmsTemplate.isPubSubDomain()).isTrue();
assertThat(defaultMessageListenerContainer.isPubSubDomain()).isTrue();
}
use of org.springframework.jms.core.JmsTemplate in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testJmsTemplateFullCustomization.
@Test
public void testJmsTemplateFullCustomization() {
load(MessageConvertersConfiguration.class, "spring.jms.template.default-destination=testQueue", "spring.jms.template.delivery-delay=500", "spring.jms.template.delivery-mode=non-persistent", "spring.jms.template.priority=6", "spring.jms.template.time-to-live=6000", "spring.jms.template.receive-timeout=2000");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
assertThat(jmsTemplate.getMessageConverter()).isSameAs(this.context.getBean("myMessageConverter"));
assertThat(jmsTemplate.isPubSubDomain()).isFalse();
assertThat(jmsTemplate.getDefaultDestinationName()).isEqualTo("testQueue");
assertThat(jmsTemplate.getDeliveryDelay()).isEqualTo(500);
assertThat(jmsTemplate.getDeliveryMode()).isEqualTo(1);
assertThat(jmsTemplate.getPriority()).isEqualTo(6);
assertThat(jmsTemplate.getTimeToLive()).isEqualTo(6000);
assertThat(jmsTemplate.isExplicitQosEnabled()).isTrue();
assertThat(jmsTemplate.getReceiveTimeout()).isEqualTo(2000);
}
Aggregations