From 8fdf3457e315b12cf99b6449305e18afe7df8628 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Fri, 11 Feb 2011 13:48:33 +0000 Subject: [PATCH] resolve regression of some ra transaction tests, follow on from http://svn.apache.org/viewvc?view=revision&revision=1065688 - a shared context needs to be aware that ended transactions that are unresolved are considered active. browse needs to only commit for local transactions when ending git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1069796 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/activemq/ActiveMQQueueBrowser.java | 2 +- .../org/apache/activemq/ra/ManagedTransactionContext.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java index 7f2fb92144..c8c25d676b 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java @@ -113,7 +113,7 @@ public class ActiveMQQueueBrowser implements QueueBrowser, Enumeration { return; } try { - if (session.getTransacted()) { + if (session.getTransacted() && session.getTransactionContext().isInLocalTransaction()) { session.commit(); } consumer.close(); diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java index 13fca74556..75c7b74714 100755 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java @@ -115,7 +115,9 @@ public class ManagedTransactionContext extends TransactionContext { public boolean isInXATransaction() { if (useSharedTxContext) { - return sharedContext.isInXATransaction(); + // context considers endesd XA transactions as active, so just check for presence + // of tx when it is shared + return sharedContext.isInTransaction(); } else { return super.isInXATransaction(); }