mirror of https://github.com/apache/activemq.git
AMQ-3988: Setting a message listener to null on AcitveMQSession should be allowed even if the session has been closed, to avoid throwning invalid state exception, that causes exceptions to be logged during shutting down apps. This allows a more clean shutdown of AMQ.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1378887 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ce702d4cf
commit
b080d5fe21
|
@ -800,6 +800,11 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
||||||
* receipt in the session can be used; however, all forms of sending
|
* receipt in the session can be used; however, all forms of sending
|
||||||
* messages are still supported.
|
* messages are still supported.
|
||||||
* <P>
|
* <P>
|
||||||
|
* If this session has been closed, then an {@link IllegalStateException} is
|
||||||
|
* thrown, if trying to set a new listener. However setting the listener
|
||||||
|
* to <tt>null</tt> is allowed, to clear the listener, even if this session
|
||||||
|
* has been closed prior.
|
||||||
|
* <P>
|
||||||
* This is an expert facility not used by regular JMS clients.
|
* This is an expert facility not used by regular JMS clients.
|
||||||
*
|
*
|
||||||
* @param listener the message listener to associate with this session
|
* @param listener the message listener to associate with this session
|
||||||
|
@ -810,7 +815,12 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
||||||
* @see javax.jms.ServerSession
|
* @see javax.jms.ServerSession
|
||||||
*/
|
*/
|
||||||
public void setMessageListener(MessageListener listener) throws JMSException {
|
public void setMessageListener(MessageListener listener) throws JMSException {
|
||||||
checkClosed();
|
// only check for closed if we set a new listener, as we allow to clear
|
||||||
|
// the listener, such as when an application is shutting down, and is
|
||||||
|
// no longer using a message listener on this session
|
||||||
|
if (listener != null) {
|
||||||
|
checkClosed();
|
||||||
|
}
|
||||||
this.messageListener = listener;
|
this.messageListener = listener;
|
||||||
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
|
|
Loading…
Reference in New Issue