activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1057853 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs
Date Tue, 11 Jan 2011 20:32:01 GMT
Author: tabish
Date: Tue Jan 11 20:32:01 2011
New Revision: 1057853

URL: http://svn.apache.org/viewvc?rev=1057853&view=rev
Log:
https://issues.apache.org/jira/browse/AMQNET-290

More enhancement to the TransactionContext to deal with DTC TX.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs?rev=1057853&r1=1057852&r2=1057853&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs
Tue Jan 11 20:32:01 2011
@@ -295,11 +295,11 @@ namespace Apache.NMS.ActiveMQ
 
         public void Commit(Enlistment enlistment)
         {
-            Tracer.Debug("Commit notification received");
-
             try
             {
-                if(this.transactionId != null)
+                Tracer.Debug("Commit notification received");
+
+                if (this.transactionId != null)
                 {
                     // Now notify the broker that a new XA'ish transaction has completed.
                     TransactionInfo info = new TransactionInfo();
@@ -322,7 +322,12 @@ namespace Apache.NMS.ActiveMQ
             {
                 Tracer.Debug("Transaction Commit failed with error: " + ex.Message);
                 AfterRollback();
-                enlistment.Done();
+                Transaction tx = Transaction.Current;
+                if(tx != null)
+                {
+                    tx.Rollback(ex);
+                }
+
                 throw;
             }
             finally
@@ -377,16 +382,17 @@ namespace Apache.NMS.ActiveMQ
         {
             Tracer.Debug("Rollback notification received");
 
-            // Now notify the broker that a new XA'ish transaction has started.
-            TransactionInfo info = new TransactionInfo();
-            info.ConnectionId = this.session.Connection.ConnectionId;
-            info.TransactionId = this.transactionId;
-
             try
             {
                 BeforeEnd();
 
-                info.Type = (int) TransactionType.End;
+                // Now notify the broker that a new XA'ish transaction has started.
+                TransactionInfo info = new TransactionInfo();
+                info.ConnectionId = this.session.Connection.ConnectionId;
+                info.TransactionId = this.transactionId;
+                info.Type = (int)TransactionType.End;
+
+                this.connection.CheckConnected();
                 this.connection.SyncRequest(info);
 
                 info.Type = (int) TransactionType.Rollback;
@@ -418,23 +424,24 @@ namespace Apache.NMS.ActiveMQ
         {
             Tracer.Debug("In doubt notification received, Rolling Back TX");
 
-            // Now notify the broker that Rollback should be performed.
-            TransactionInfo info = new TransactionInfo();
-            info.ConnectionId = this.session.Connection.ConnectionId;
-            info.TransactionId = this.transactionId;
-
             try
             {
                 BeforeEnd();
 
+                // Now notify the broker that Rollback should be performed.
+                TransactionInfo info = new TransactionInfo();
+                info.ConnectionId = this.session.Connection.ConnectionId;
+                info.TransactionId = this.transactionId;
                 info.Type = (int)TransactionType.End;
+
+                this.connection.CheckConnected();
                 this.connection.SyncRequest(info);
 
                 info.Type = (int)TransactionType.Rollback;
                 this.connection.CheckConnected();
                 this.connection.SyncRequest(info);
 
-                Tracer.Debug("Transaction Rollback Reports Done: ");
+                Tracer.Debug("InDoubt Transaction Rollback Reports Done: ");
 
                 // if server responds that nothing needs to be done, then reply done.
                 enlistment.Done();



Mime
View raw message