Skip to content

Commit 870cd77

Browse files
committed
Fix Hang in JMS Test
- add a timeout for template.receive() - don't cache consumers
1 parent aca79f8 commit 870cd77

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public void testWithTimeout() throws Exception {
9797
this.gateway2.start();
9898
this.gateway2.handleMessage(MessageBuilder.withPayload("foo").setErrorChannel(errors).build());
9999
JmsTemplate template = new JmsTemplate(this.ccf);
100+
template.setReceiveTimeout(10000);
100101
final Message received = template.receive("asyncTest3");
101102
assertNotNull(received);
102103
org.springframework.messaging.Message<?> error = errors.receive(10000);
@@ -117,6 +118,7 @@ public void testWithTimeoutNoReplyRequired() throws Exception {
117118
this.gateway2.start();
118119
this.gateway2.handleMessage(MessageBuilder.withPayload("foo").setErrorChannel(errors).build());
119120
JmsTemplate template = new JmsTemplate(this.ccf);
121+
template.setReceiveTimeout(10000);
120122
final Message received = template.receive("asyncTest3");
121123
assertNotNull(received);
122124
org.springframework.messaging.Message<?> error = errors.receive(1000);
@@ -130,8 +132,10 @@ public static class Config {
130132

131133
@Bean
132134
public CachingConnectionFactory ccf() {
133-
return new CachingConnectionFactory(
135+
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(
134136
new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"));
137+
cachingConnectionFactory.setCacheConsumers(false);
138+
return cachingConnectionFactory;
135139
}
136140

137141
@Bean

0 commit comments

Comments
 (0)