DefaultMessageListenerContainer uses receiveTimeout for wait call on shutdown

Issue: SPR-11841
This commit is contained in:
Juergen Hoeller 2015-04-16 22:49:45 +02:00
parent cddcf3637d
commit d398bb7c51
2 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -169,6 +169,14 @@ public abstract class AbstractPollingMessageListenerContainer extends AbstractMe
this.receiveTimeout = receiveTimeout;
}
/**
* Return the receive timeout (ms) configured for this listener container.
* @since 4.2
*/
protected long getReceiveTimeout() {
return this.receiveTimeout;
}
@Override
public void initialize() {

View File

@ -563,7 +563,13 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
logger.debug("Still waiting for shutdown of " + this.activeInvokerCount +
" message listener invokers");
}
this.lifecycleMonitor.wait();
long timeout = getReceiveTimeout();
if (timeout > 0) {
this.lifecycleMonitor.wait(timeout);
}
else {
this.lifecycleMonitor.wait();
}
}
// Clear remaining scheduled invokers, possibly left over as paused tasks...
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {