You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2011/02/09 22:09:29 UTC

svn commit: r1069105 - in /qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport: Connection.java Session.java

Author: rajith
Date: Wed Feb  9 21:09:28 2011
New Revision: 1069105

URL: http://svn.apache.org/viewvc?rev=1069105&view=rev
Log:
QPID-2994
The commit made in rev 1068661 will only close and throw an exception if the user tries to invoke an action (Ex sending a message or calling commit) on the transactional session while failover is in progress (i.e session in detached state).
We also need to handle the case where the application is not doing anything during failover. But the application may still be in the middle of an uncommitted transaction. Therefore any session that is marked transactional should not be resumed.

This commit removes tranactional sessions and close them inside the 'resume' method in Connection.java
Any subsequent operation on this session will cause an exception being thrown, saying the session is closed.
However the exception doesn't really contain the reason, other than to say the session is closed.

The Java client in general needs a better error reporting scheme to convey more information to a client application.
That will be handled under a separate JIRA.

For the purpose of this JIRA the session being closed is good enough for the time being.

Modified:
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java

Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java?rev=1069105&r1=1069104&r2=1069105&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java (original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java Wed Feb  9 21:09:28 2011
@@ -463,9 +463,17 @@ public class Connection extends Connecti
         {
             for (Session ssn : sessions.values())
             {
-                map(ssn);
-                ssn.attach();
-                ssn.resume();
+                if (ssn.isTransacted())
+                {                    
+                    removeSession(ssn);
+                    ssn.setState(Session.State.CLOSED);
+                }
+                else
+                {                
+                    map(ssn);
+                    ssn.attach();
+                    ssn.resume();
+                }
             }
         }
     }

Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java?rev=1069105&r1=1069104&r2=1069105&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java (original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java Wed Feb  9 21:09:28 2011
@@ -536,6 +536,7 @@ public class Session extends SessionInvo
             if (state == DETACHED && transacted)
             {
                 state = CLOSED;
+                delegate.closed(this);
                 connection.removeSession(this);
                 throw new SessionException(
                         "Session failed over, possibly in the middle of a transaction. " +
@@ -1012,4 +1013,8 @@ public class Session extends SessionInvo
         this.transacted = b;
     }
     
+    public boolean isTransacted(){
+        return transacted;
+    }
+    
 }



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