Skip to content

Commit d398bb7

Browse files
committed
DefaultMessageListenerContainer uses receiveTimeout for wait call on shutdown
Issue: SPR-11841
1 parent cddcf36 commit d398bb7

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

spring-jms/src/main/java/org/springframework/jms/listener/AbstractPollingMessageListenerContainer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -169,6 +169,14 @@ public void setReceiveTimeout(long receiveTimeout) {
169169
this.receiveTimeout = receiveTimeout;
170170
}
171171

172+
/**
173+
* Return the receive timeout (ms) configured for this listener container.
174+
* @since 4.2
175+
*/
176+
protected long getReceiveTimeout() {
177+
return this.receiveTimeout;
178+
}
179+
172180

173181
@Override
174182
public void initialize() {

spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,13 @@ protected void doShutdown() throws JMSException {
563563
logger.debug("Still waiting for shutdown of " + this.activeInvokerCount +
564564
" message listener invokers");
565565
}
566-
this.lifecycleMonitor.wait();
566+
long timeout = getReceiveTimeout();
567+
if (timeout > 0) {
568+
this.lifecycleMonitor.wait(timeout);
569+
}
570+
else {
571+
this.lifecycleMonitor.wait();
572+
}
567573
}
568574
// Clear remaining scheduled invokers, possibly left over as paused tasks...
569575
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {

0 commit comments

Comments
 (0)