Fix Hang in JMS Test

- add a timeout for template.receive()
- don't cache consumers
This commit is contained in:
Gary Russell
2018-01-24 14:09:03 -05:00
parent 6a86f5231d
commit f5a00af438

View File

@@ -104,6 +104,7 @@ public class AsyncGatewayTests {
this.gateway2.start();
this.gateway2.handleMessage(MessageBuilder.withPayload("foo").setErrorChannel(errors).build());
JmsTemplate template = new JmsTemplate(this.ccf);
template.setReceiveTimeout(10000);
final Message received = template.receive("asyncTest3");
assertNotNull(received);
org.springframework.messaging.Message<?> error = errors.receive(10000);
@@ -124,6 +125,7 @@ public class AsyncGatewayTests {
this.gateway2.start();
this.gateway2.handleMessage(MessageBuilder.withPayload("foo").setErrorChannel(errors).build());
JmsTemplate template = new JmsTemplate(this.ccf);
template.setReceiveTimeout(10000);
final Message received = template.receive("asyncTest3");
assertNotNull(received);
org.springframework.messaging.Message<?> error = errors.receive(1000);
@@ -137,8 +139,10 @@ public class AsyncGatewayTests {
@Bean
public CachingConnectionFactory ccf() {
return new CachingConnectionFactory(
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(
new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"));
cachingConnectionFactory.setCacheConsumers(false);
return cachingConnectionFactory;
}
@Bean