activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [18/50] [abbrv] activemq-nms-openwire git commit: Merged revision(s) 1689517 from activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk: Apply patch from Jose Alvarado. Thanks, Jose! Fixes [AMQNET-503]. (See https://issues.apache.org/jira/browse/AMQNET-503)
Date Wed, 08 Mar 2017 23:12:20 GMT
Merged revision(s) 1689517 from activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk:
Apply patch from Jose Alvarado. Thanks, Jose!
Fixes [AMQNET-503]. (See https://issues.apache.org/jira/browse/AMQNET-503)


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

Branch: refs/heads/1.7.x
Commit: d13fe5c9717e96d371897f0db8e28bc2b758a1f6
Parents: 03dbbaf
Author: Jim Gomes <jgomes@apache.org>
Authored: Tue Jul 7 00:02:01 2015 +0000
Committer: Jim Gomes <jgomes@apache.org>
Committed: Tue Jul 7 00:02:01 2015 +0000

----------------------------------------------------------------------
 nant.build                                    |  2 +-
 src/main/csharp/NetTxConnection.cs            | 15 ++++++++++++
 src/main/csharp/NetTxMessageConsumer.cs       | 27 +++++++++++++++++++---
 src/main/csharp/NetTxSession.cs               | 10 ++++++++
 src/test/csharp/DtcTransactionsTestSupport.cs | 11 +++++----
 5 files changed, 56 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/d13fe5c9/nant.build
----------------------------------------------------------------------
diff --git a/nant.build b/nant.build
index f9247cb..073ec67 100644
--- a/nant.build
+++ b/nant.build
@@ -51,7 +51,7 @@
         <!-- Property grouping for 'vendor.apache.org' -->
         <property name="vendor.apache.org.name" value="Apache.NMS" />
         <property name="vendor.apache.org.group" value="org.apache.activemq" />
-        <property name="vendor.apache.org.version" value="1.7.0" />
+        <property name="vendor.apache.org.version" value="1.7.1" />
         <if test="${current.build.framework == 'mono-2.0' or current.build.framework ==
'mono-4.0'}">
             <property name="vendor.apache.org.filenames" value="Apache.NMS.dll,Apache.NMS.dll.mdb,Apache.NMS.Test.dll,Apache.NMS.Test.dll.mdb"
/>
         </if>

http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/d13fe5c9/src/main/csharp/NetTxConnection.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/NetTxConnection.cs b/src/main/csharp/NetTxConnection.cs
index bc174b7..8f1976c 100644
--- a/src/main/csharp/NetTxConnection.cs
+++ b/src/main/csharp/NetTxConnection.cs
@@ -51,6 +51,21 @@ namespace Apache.NMS.ActiveMQ
             return session;
         }
 
+        public INetTxSession CreateNetTxSession(Transaction tx, bool enlistNativeMsDtcResource)
+        {
+            NetTxSession session = (NetTxSession)CreateSession(AcknowledgementMode.Transactional);
+            session.Enlist(tx);
+            session.EnlistsMsDtcNativeResource = enlistNativeMsDtcResource;
+            return session;
+        }
+
+        public INetTxSession CreateNetTxSession(bool enlistNativeMsDtcResource)
+        {
+            NetTxSession session = (NetTxSession)CreateSession(AcknowledgementMode.Transactional);
+            session.EnlistsMsDtcNativeResource = enlistNativeMsDtcResource;
+            return session;
+        }
+
         protected override Session CreateActiveMQSession(AcknowledgementMode ackMode)
         {
             CheckConnected();

http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/d13fe5c9/src/main/csharp/NetTxMessageConsumer.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/NetTxMessageConsumer.cs b/src/main/csharp/NetTxMessageConsumer.cs
index 6a9a65c..f4ef109 100644
--- a/src/main/csharp/NetTxMessageConsumer.cs
+++ b/src/main/csharp/NetTxMessageConsumer.cs
@@ -18,6 +18,7 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using System.Transactions;
 using Apache.NMS.ActiveMQ.Commands;
 
 namespace Apache.NMS.ActiveMQ
@@ -75,9 +76,29 @@ namespace Apache.NMS.ActiveMQ
                         // distributed TX manager we need to wait whenever the TX is being
                         // controlled by the DTC as it completes all operations async and
                         // we cannot start consumption again until all its tasks have completed.)
-                        waitForDtcWaitHandle = this.transactionContext.InNetTransaction &&
-                                               this.transactionContext.NetTxState ==
-                                               NetTxTransactionContext.TxState.Pending;
+                        var currentTransactionId = transactionContext.TransactionId as XATransactionId;
+                        string currentLocalTxId = currentTransactionId != null
+                            ? UTF8Encoding.UTF8.GetString(currentTransactionId.GlobalTransactionId)
+                            : "NONE";
+
+                        if (Transaction.Current != null)
+                        {
+                            waitForDtcWaitHandle = this.transactionContext.InNetTransaction
&&
+                                               this.transactionContext.NetTxState == NetTxTransactionContext.TxState.Pending
||
+                                               currentLocalTxId != Transaction.Current.TransactionInformation.LocalIdentifier;
+                        }
+                        else
+                        {
+                            waitForDtcWaitHandle = this.transactionContext.InNetTransaction
&&
+                                               this.transactionContext.NetTxState == NetTxTransactionContext.TxState.Pending;
+                        }
+                        
+                    }
+
+                    //if session EnlistMsDtcNativeResource the transaction does not need
to wait
+                    if (this.session.EnlistsMsDtcNativeResource)
+                    {
+                        waitForDtcWaitHandle = false;
                     }
 
                     if (waitForDtcWaitHandle)

http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/d13fe5c9/src/main/csharp/NetTxSession.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/NetTxSession.cs b/src/main/csharp/NetTxSession.cs
index 8da035b..f7e754b 100644
--- a/src/main/csharp/NetTxSession.cs
+++ b/src/main/csharp/NetTxSession.cs
@@ -32,6 +32,7 @@ namespace Apache.NMS.ActiveMQ
         {
             this.transactionContext = TransactionContext as NetTxTransactionContext;
             this.transactionContext.InitializeDtcTxContext();
+            this.enlistMsDtcNativeResources = false;
         }
 
         /// <summary>
@@ -51,6 +52,14 @@ namespace Apache.NMS.ActiveMQ
             this.EnrollInSpecifiedTransaction(tx);
         }
 
+        private bool enlistMsDtcNativeResources;
+
+        public bool EnlistsMsDtcNativeResource
+        {
+            get { return enlistMsDtcNativeResources; }
+            set { enlistMsDtcNativeResources = value; }
+        }
+
         /// <summary>
         /// Reports Transacted whenever there is an Ambient Transaction or the internal
         /// TransactionContext is still involed in a .NET Transaction beyond the lifetime
@@ -173,6 +182,7 @@ namespace Apache.NMS.ActiveMQ
             this.currentTransactionId = tx.TransactionInformation.LocalIdentifier; 
             transactionContext.Begin(tx);
         }
+        
     }
 }
 

http://git-wip-us.apache.org/repos/asf/activemq-nms-openwire/blob/d13fe5c9/src/test/csharp/DtcTransactionsTestSupport.cs
----------------------------------------------------------------------
diff --git a/src/test/csharp/DtcTransactionsTestSupport.cs b/src/test/csharp/DtcTransactionsTestSupport.cs
index 2ce121f..030a9d3 100644
--- a/src/test/csharp/DtcTransactionsTestSupport.cs
+++ b/src/test/csharp/DtcTransactionsTestSupport.cs
@@ -53,7 +53,8 @@ namespace Apache.NMS.ActiveMQ.Test
         private ITrace oldTracer;
 
         protected const string sqlConnectionString =
-            "Data Source=localhost;Initial Catalog=TestDB;User ID=user;Password=password";
+            // "Data Source=localhost;Initial Catalog=TestDB;User ID=user;Password=password";
+            "Data Source=.\\SQLEXPRESS;Initial Catalog=TestDB;Integrated Security = true";
         protected const string testTable = "TestTable";
         protected const string testColumn = "TestID";
         protected const string testQueueName = "TestQueue";
@@ -484,7 +485,7 @@ namespace Apache.NMS.ActiveMQ.Test
         {
             IList entries = ExtractDataSet();
 
-            using (INetTxSession session = connection.CreateNetTxSession())
+            using (INetTxSession session = connection.CreateNetTxSession(true))
             {
                 IQueue queue = session.GetQueue(testQueueName);
 
@@ -531,7 +532,7 @@ namespace Apache.NMS.ActiveMQ.Test
         {
             IList entries = ExtractDataSet();
 
-            using (INetTxSession session = connection.CreateNetTxSession())
+            using (INetTxSession session = connection.CreateNetTxSession(true))
             {
                 IQueue queue = session.GetQueue(testQueueName);
 
@@ -578,7 +579,7 @@ namespace Apache.NMS.ActiveMQ.Test
 
         protected static void ReadFromQueueAndInsertIntoDbWithCommit(INetTxConnection connection)
         {
-            using (INetTxSession session = connection.CreateNetTxSession())
+            using (INetTxSession session = connection.CreateNetTxSession(true))
             {
                 IQueue queue = session.GetQueue(testQueueName);
 
@@ -619,7 +620,7 @@ namespace Apache.NMS.ActiveMQ.Test
 
         protected static void ReadFromQueueAndInsertIntoDbWithScopeAborted(INetTxConnection
connection)
         {
-            using (INetTxSession session = connection.CreateNetTxSession())
+            using (INetTxSession session = connection.CreateNetTxSession(true))
             {
                 IQueue queue = session.GetQueue(testQueueName);
 


Mime
View raw message