activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-5189
Date Thu, 29 May 2014 14:33:22 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk f2653e693 -> 9f78f8237


https://issues.apache.org/jira/browse/AMQ-5189

Set all session properties back using a session listener close event so
that the returned session is not modified after it's already been
re-dispatched from the pool.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/9f78f823
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/9f78f823
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/9f78f823

Branch: refs/heads/trunk
Commit: 9f78f823784e4bde3bfe45b6aa298d6523319c1d
Parents: f2653e6
Author: Timothy Bish <tabish121@gmail.com>
Authored: Thu May 29 10:33:09 2014 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Thu May 29 10:33:09 2014 -0400

----------------------------------------------------------------------
 .../activemq/jms/pool/XaConnectionPool.java     | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/9f78f823/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaConnectionPool.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaConnectionPool.java
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaConnectionPool.java
index f4205c8..4f87153 100644
--- a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaConnectionPool.java
+++ b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaConnectionPool.java
@@ -19,6 +19,8 @@ package org.apache.activemq.jms.pool;
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
 import javax.jms.XAConnection;
 import javax.transaction.RollbackException;
 import javax.transaction.Status;
@@ -27,10 +29,9 @@ import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAResource;
 
 /**
- * An XA-aware connection pool.  When a session is created and an xa transaction is active,
- * the session will automatically be enlisted in the current transaction.
- *
- * @author gnodet
+ * An XA-aware connection pool. When a session is created and an xa transaction
+ * is active, the session will automatically be enlisted in the current
+ * transaction.
  */
 public class XaConnectionPool extends ConnectionPool {
 
@@ -43,7 +44,7 @@ public class XaConnectionPool extends ConnectionPool {
 
     @Override
     protected Session makeSession(SessionKey key) throws JMSException {
-        return ((XAConnection)connection).createXASession();
+        return ((XAConnection) connection).createXASession();
     }
 
     @Override
@@ -51,7 +52,8 @@ public class XaConnectionPool extends ConnectionPool {
         try {
             boolean isXa = (transactionManager != null && transactionManager.getStatus()
!= Status.STATUS_NO_TRANSACTION);
             if (isXa) {
-                // if the xa tx aborts inflight we don't want to auto create a local transaction
or auto ack
+                // if the xa tx aborts inflight we don't want to auto create a
+                // local transaction or auto ack
                 transacted = false;
                 ackMode = Session.CLIENT_ACKNOWLEDGE;
             } else if (transactionManager != null) {
@@ -63,6 +65,22 @@ public class XaConnectionPool extends ConnectionPool {
             }
             PooledSession session = (PooledSession) super.createSession(transacted, ackMode);
             if (isXa) {
+                session.addSessionEventListener(new PooledSessionEventListener() {
+
+                    @Override
+                    public void onTemporaryQueueCreate(TemporaryQueue tempQueue) {
+                    }
+
+                    @Override
+                    public void onTemporaryTopicCreate(TemporaryTopic tempTopic) {
+                    }
+
+                    @Override
+                    public void onSessionClosed(PooledSession session) {
+                        session.setIgnoreClose(true);
+                        session.setIsXa(false);
+                    }
+                });
                 session.setIgnoreClose(true);
                 session.setIsXa(true);
                 transactionManager.getTransaction().registerSynchronization(new Synchronization(session));
@@ -104,8 +122,6 @@ public class XaConnectionPool extends ConnectionPool {
                 // This will return session to the pool.
                 session.setIgnoreClose(false);
                 session.close();
-                session.setIgnoreClose(true);
-                session.setIsXa(false);
                 decrementReferenceCount();
             } catch (JMSException e) {
                 throw new RuntimeException(e);


Mime
View raw message