Author: gtully
Date: Wed Apr  3 10:35:56 2013
New Revision: 1463908

URL: http://svn.apache.org/r1463908
Log:
https://issues.apache.org/jira/browse/AMQ-4426 - for cmt, ignore args to create 
session when tm and no tx, so session_transacted is not passed down to cf, 
avoid config error ex

Modified:
    
activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/XaConnectionPool.java
    
activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java

Modified: 
activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/XaConnectionPool.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/XaConnectionPool.java?rev=1463908&r1=1463907&r2=1463908&view=diff
==============================================================================
--- 
activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/XaConnectionPool.java
 (original)
+++ 
activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/XaConnectionPool.java
 Wed Apr  3 10:35:56 2013
@@ -48,6 +48,12 @@ public class XaConnectionPool extends Co
             if (isXa) {
                 transacted = true;
                 ackMode = Session.SESSION_TRANSACTED;
+            } else if (transactionManager != null) {
+                // cmt or transactionManager managed
+                transacted = false;
+                if (ackMode == Session.SESSION_TRANSACTED) {
+                    ackMode = Session.AUTO_ACKNOWLEDGE;
+                }
             }
             PooledSession session = (PooledSession) 
super.createSession(transacted, ackMode);
             if (isXa) {

Modified: 
activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java?rev=1463908&r1=1463907&r2=1463908&view=diff
==============================================================================
--- 
activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java
 (original)
+++ 
activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java
 Wed Apr  3 10:35:56 2013
@@ -191,4 +191,60 @@ public class XAConnectionPoolTest extend
         topicConnection.close();
     }
 
+    public void testSessionArgsIgnoredWithTm() throws Exception {
+        XaPooledConnectionFactory pcf = new XaPooledConnectionFactory();
+        pcf.setConnectionFactory(new 
ActiveMQConnectionFactory("vm://test?broker.persistent=false"));
+        // simple TM that with no tx
+        pcf.setTransactionManager(new TransactionManager() {
+            @Override
+            public void begin() throws NotSupportedException, SystemException {
+                throw new SystemException("NoTx");
+            }
+
+            @Override
+            public void commit() throws HeuristicMixedException, 
HeuristicRollbackException, IllegalStateException, RollbackException, 
SecurityException, SystemException {
+                throw new IllegalStateException("NoTx");
+            }
+
+            @Override
+            public int getStatus() throws SystemException {
+                return Status.STATUS_NO_TRANSACTION;
+            }
+
+            @Override
+            public Transaction getTransaction() throws SystemException {
+                throw new SystemException("NoTx");
+            }
+
+            @Override
+            public void resume(Transaction tobj) throws IllegalStateException, 
InvalidTransactionException, SystemException {
+                throw new IllegalStateException("NoTx");
+            }
+
+            @Override
+            public void rollback() throws IllegalStateException, 
SecurityException, SystemException {
+                throw new IllegalStateException("NoTx");
+            }
+
+            @Override
+            public void setRollbackOnly() throws IllegalStateException, 
SystemException {
+                throw new IllegalStateException("NoTx");
+            }
+
+            @Override
+            public void setTransactionTimeout(int seconds) throws 
SystemException {
+            }
+
+            @Override
+            public Transaction suspend() throws SystemException {
+                throw new SystemException("NoTx");
+            }
+        });
+
+        QueueConnection connection = pcf.createQueueConnection();
+        // like ee tck
+        assertNotNull("can create session(false, 0)", 
connection.createQueueSession(false, 0));
+
+        connection.close();
+    }
 }


Reply via email to