From f5a00af438d48c87e843ea2a823ba0253d3858c6 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 24 Jan 2018 14:09:03 -0500 Subject: [PATCH] Fix Hang in JMS Test - add a timeout for template.receive() - don't cache consumers --- .../integration/jms/request_reply/AsyncGatewayTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java index 64e06be696..e4bb4c396e 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java @@ -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