You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2009/10/28 16:31:21 UTC

svn commit: r830592 - in /qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client: failover/FailoverHandler.java state/AMQStateManager.java

Author: ritchiem
Date: Wed Oct 28 15:31:20 2009
New Revision: 830592

URL: http://svn.apache.org/viewvc?rev=830592&view=rev
Log:
QPID-1816 : When client fails over due to an error, that error is still held bt the StateManager and will prvent the connection from working. During failover check and see if the Connection had been marked closed if so remove any set exception.

Modified:
    qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
    qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java

Modified: qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java?rev=830592&r1=830591&r2=830592&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java Wed Oct 28 15:31:20 2009
@@ -25,6 +25,7 @@
 import org.apache.qpid.AMQDisconnectedException;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.client.state.AMQStateManager;
+import org.apache.qpid.client.state.AMQState;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -216,6 +217,22 @@
                 // Set the new Protocol Session in the StateManager.               
                 existingStateManager.setProtocolSession(_amqProtocolHandler.getProtocolSession());
 
+                // Now that the ProtocolHandler has been reconnected clean up
+                // the state of the old state manager. As if we simply reinstate
+                // it any old exception that had occured prior to failover may
+                // prohibit reconnection.
+                // e.g. During testing when the broker is shutdown gracefully.
+                // The broker 
+                // Clear any exceptions we gathered
+                if (existingStateManager.getCurrentState() != AMQState.CONNECTION_OPEN)
+                {
+                    // Clear the state of the previous state manager as it may
+                    // have received an exception
+                    existingStateManager.clearLastException();
+                    existingStateManager.changeState(AMQState.CONNECTION_OPEN);
+                }
+
+
                 //Restore Existing State Manager
                 _amqProtocolHandler.setStateManager(existingStateManager);
                 try

Modified: qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java?rev=830592&r1=830591&r2=830592&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java Wed Oct 28 15:31:20 2009
@@ -213,4 +213,9 @@
     {
         return _lastException;
     }
+
+    public void clearLastException()
+    {
+        _lastException = null;
+    }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org