Skip to content

Commit 6b3284f

Browse files
committed
DefaultMessageListenerContainer clears resources of paused tasks when shutting down after stop
Issue: SPR-10092
1 parent 431c7ff commit 6b3284f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ public void shutdown() throws JmsException {
214214
wasRunning = this.running;
215215
this.running = false;
216216
this.active = false;
217+
this.pausedTasks.clear();
217218
this.lifecycleMonitor.notifyAll();
218219
}
219220

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,10 @@ public final int getConcurrentConsumers() {
337337
* to scale the consumption of messages coming in from a queue. However,
338338
* note that any ordering guarantees are lost once multiple consumers are
339339
* registered. In general, stick with 1 consumer for low-volume queues.
340-
* <p><b>Do not raise the number of concurrent consumers for a topic.</b>
341-
* This would lead to concurrent consumption of the same message,
342-
* which is hardly ever desirable.
340+
* <p><b>Do not raise the number of concurrent consumers for a topic,
341+
* unless vendor-specific setup measures clearly allow for it.</b>
342+
* With regular setup, this would lead to concurrent consumption
343+
* of the same message, which is hardly ever desirable.
343344
* <p><b>This setting can be modified at runtime, for example through JMX.</b>
344345
* @see #setConcurrentConsumers
345346
*/
@@ -526,13 +527,19 @@ protected void doShutdown() throws JMSException {
526527
logger.debug("Waiting for shutdown of message listener invokers");
527528
try {
528529
synchronized (this.lifecycleMonitor) {
530+
// Waiting for AsyncMessageListenerInvokers to deactivate themselves...
529531
while (this.activeInvokerCount > 0) {
530532
if (logger.isDebugEnabled()) {
531533
logger.debug("Still waiting for shutdown of " + this.activeInvokerCount +
532534
" message listener invokers");
533535
}
534536
this.lifecycleMonitor.wait();
535537
}
538+
// Clear remaining scheduled invokers, possibly left over as paused tasks...
539+
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {
540+
scheduledInvoker.clearResources();
541+
}
542+
this.scheduledInvokers.clear();
536543
}
537544
}
538545
catch (InterruptedException ex) {

0 commit comments

Comments
 (0)