You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by da...@apache.org on 2012/08/30 13:15:32 UTC

svn commit: r1378887 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java

Author: davsclaus
Date: Thu Aug 30 11:15:32 2012
New Revision: 1378887

URL: http://svn.apache.org/viewvc?rev=1378887&view=rev
Log:
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.

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java?rev=1378887&r1=1378886&r2=1378887&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java Thu Aug 30 11:15:32 2012
@@ -800,6 +800,11 @@ public class ActiveMQSession implements 
      * receipt in the session can be used; however, all forms of sending
      * messages are still supported.
      * <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.
      *
      * @param listener the message listener to associate with this session
@@ -810,7 +815,12 @@ public class ActiveMQSession implements 
      * @see javax.jms.ServerSession
      */
     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;
 
         if (listener != null) {