You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2011/01/06 21:09:38 UTC

svn commit: r1056052 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs

Author: tabish
Date: Thu Jan  6 20:09:38 2011
New Revision: 1056052

URL: http://svn.apache.org/viewvc?rev=1056052&view=rev
Log:
Update the distributed transaction code to enlist as a durable provider so that dependent resource providers get rolled back if the commit step of the amq transaction fails.

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=1056052&r1=1056051&r2=1056052&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 Thu Jan  6 20:09:38 2011
@@ -205,9 +205,13 @@ namespace Apache.NMS.ActiveMQ
                 throw new TransactionInProgressException("A Transaction is already in Progress");
             }
 
+            Guid rmId = GuidFromId(this.connection.ResourceManagerId);
+
             // Enlist this object in the transaction.
             this.currentEnlistment =
-                transaction.EnlistVolatile(this, EnlistmentOptions.None);
+                transaction.EnlistDurable(rmId, this, EnlistmentOptions.None);
+
+            Tracer.Debug("Enlisted in Durable Transaction with RM Id: " + rmId.ToString());
 
             System.Transactions.TransactionInformation txInfo = transaction.TransactionInformation;
 
@@ -403,6 +407,29 @@ namespace Apache.NMS.ActiveMQ
             }
         }
 
+        public XATransactionId[] Recover()
+        {
+            TransactionInfo info = new TransactionInfo();
+            info.ConnectionId = this.session.Connection.ConnectionId;
+            info.Type = (int)TransactionType.Recover;
+
+            this.connection.CheckConnected();
+            DataArrayResponse response = this.connection.SyncRequest(info) as DataArrayResponse;
+            
+            if(response != null && response.Data.Length > 0)
+            {
+                XATransactionId[] result = null;
+                if (response.Data is XATransactionId[])
+                {
+                    result = new XATransactionId[response.Data.Length];
+                    System.Array.Copy(response.Data, result, response.Data.Length);
+                    return result;
+                }
+            }
+
+            return new XATransactionId[0];
+        }
+
         #endregion
 
         private Guid GuidFromId(string id)