DefaultMessageListenerContainer clears resources of paused tasks when shutting down after stop

Issue: SPR-10092
This commit is contained in:
Juergen Hoeller
2012-12-13 11:29:40 +01:00
parent 431c7ff31f
commit 6b3284f6b0
2 changed files with 11 additions and 3 deletions

View File

@@ -214,6 +214,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
wasRunning = this.running;
this.running = false;
this.active = false;
this.pausedTasks.clear();
this.lifecycleMonitor.notifyAll();
}

View File

@@ -337,9 +337,10 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
* to scale the consumption of messages coming in from a queue. However,
* note that any ordering guarantees are lost once multiple consumers are
* registered. In general, stick with 1 consumer for low-volume queues.
* <p><b>Do not raise the number of concurrent consumers for a topic.</b>
* This would lead to concurrent consumption of the same message,
* which is hardly ever desirable.
* <p><b>Do not raise the number of concurrent consumers for a topic,
* unless vendor-specific setup measures clearly allow for it.</b>
* With regular setup, this would lead to concurrent consumption
* of the same message, which is hardly ever desirable.
* <p><b>This setting can be modified at runtime, for example through JMX.</b>
* @see #setConcurrentConsumers
*/
@@ -526,6 +527,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
logger.debug("Waiting for shutdown of message listener invokers");
try {
synchronized (this.lifecycleMonitor) {
// Waiting for AsyncMessageListenerInvokers to deactivate themselves...
while (this.activeInvokerCount > 0) {
if (logger.isDebugEnabled()) {
logger.debug("Still waiting for shutdown of " + this.activeInvokerCount +
@@ -533,6 +535,11 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
}
this.lifecycleMonitor.wait();
}
// Clear remaining scheduled invokers, possibly left over as paused tasks...
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {
scheduledInvoker.clearResources();
}
this.scheduledInvokers.clear();
}
}
catch (InterruptedException ex) {