Skip to content

Commit f5a00af

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

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
@@ -104,6 +104,7 @@ public void testWithTimeout() throws Exception {
104104
this.gateway2.start();
105105
this.gateway2.handleMessage(MessageBuilder.withPayload("foo").setErrorChannel(errors).build());
106106
JmsTemplate template = new JmsTemplate(this.ccf);
107+
template.setReceiveTimeout(10000);
107108
final Message received = template.receive("asyncTest3");
108109
assertNotNull(received);
109110
org.springframework.messaging.Message<?> error = errors.receive(10000);
@@ -124,6 +125,7 @@ public void testWithTimeoutNoReplyRequired() throws Exception {
124125
this.gateway2.start();
125126
this.gateway2.handleMessage(MessageBuilder.withPayload("foo").setErrorChannel(errors).build());
126127
JmsTemplate template = new JmsTemplate(this.ccf);
128+
template.setReceiveTimeout(10000);
127129
final Message received = template.receive("asyncTest3");
128130
assertNotNull(received);
129131
org.springframework.messaging.Message<?> error = errors.receive(1000);
@@ -137,8 +139,10 @@ public static class Config {
137139

138140
@Bean
139141
public CachingConnectionFactory ccf() {
140-
return new CachingConnectionFactory(
142+
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(
141143
new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"));
144+
cachingConnectionFactory.setCacheConsumers(false);
145+
return cachingConnectionFactory;
142146
}
143147

144148
@Bean

0 commit comments

Comments
 (0)