activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1097112 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp: NetTxSession.cs Session.cs
Date Wed, 27 Apr 2011 13:51:38 GMT
Author: tabish
Date: Wed Apr 27 13:51:38 2011
New Revision: 1097112

URL: http://svn.apache.org/viewvc?rev=1097112&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQNET-326

Move the DTC TX detection logic for close up into the NetTxSession class, its not needed for
a normal Session object.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/NetTxSession.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Session.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/NetTxSession.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/NetTxSession.cs?rev=1097112&r1=1097111&r2=1097112&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/NetTxSession.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/NetTxSession.cs
Wed Apr 27 13:51:38 2011
@@ -64,6 +64,39 @@ namespace Apache.NMS.ActiveMQ
             get { return true; }
         }
 
+        public override void Close()
+        {
+            if (this.closed)
+            {
+                return;
+            }
+
+            try
+            {
+                if (TransactionContext.InNetTransaction)
+                {
+                    TransactionContext.SyncRoot.WaitOne();
+
+                    if (TransactionContext.InNetTransaction)
+                    {
+                        // Must wait for all the DTC operations to complete before
+                        // moving on from this close call.
+                        TransactionContext.SyncRoot.ReleaseMutex();
+                        this.TransactionContext.DtcWaitHandle.WaitOne();
+                        TransactionContext.SyncRoot.WaitOne();
+                    }
+
+                    TransactionContext.SyncRoot.ReleaseMutex();
+                }
+
+                base.Close();
+            }
+            catch (Exception ex)
+            {
+                Tracer.ErrorFormat("Error during session close: {0}", ex);
+            }
+        }
+
         internal override void DoRollback()
         {
             // Only the Transaction Manager can do this when in a .NET Transaction.

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Session.cs?rev=1097112&r1=1097111&r2=1097112&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Session.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Session.cs
Wed Apr 27 13:51:38 2011
@@ -53,9 +53,9 @@ namespace Apache.NMS.ActiveMQ
         private int producerCounter;
         private long nextDeliveryId;
         private long lastDeliveredSequenceId;
-        private bool disposed = false;
-        private bool closed = false;
-        private bool closing = false;
+        protected bool disposed = false;
+        protected bool closed = false;
+        protected bool closing = false;
         private TimeSpan disposeStopTimeout = TimeSpan.FromMilliseconds(30000);
         private TimeSpan closeStopTimeout = TimeSpan.FromMilliseconds(Timeout.Infinite);
         private TimeSpan requestTimeout;
@@ -300,38 +300,20 @@ namespace Apache.NMS.ActiveMQ
             this.disposed = true;
         }
 
-        public void Close()
+        public virtual void Close()
         {
-            if(this.closed)
+            if (!this.closed)
             {
-                return;
-            }
-
-            try
-            {                
-                if (transactionContext.InNetTransaction)
+                try
                 {
-                    TransactionContext.SyncRoot.WaitOne();
-
-                    if (transactionContext.InNetTransaction)
-                    {
-                        // Must wait for all the DTC operations to complete before
-                        // moving on from this close call.
-                        TransactionContext.SyncRoot.ReleaseMutex();
-                        this.transactionContext.DtcWaitHandle.WaitOne();
-                        TransactionContext.SyncRoot.WaitOne();
-                    }
-
-                    TransactionContext.SyncRoot.ReleaseMutex();
+                    Tracer.InfoFormat("Closing The Session with Id {0}", this.info.SessionId);
+                    DoClose();
+                    Tracer.InfoFormat("Closed The Session with Id {0}", this.info.SessionId);
+                }
+                catch (Exception ex)
+                {
+                    Tracer.ErrorFormat("Error during session close: {0}", ex);
                 }
-
-                Tracer.InfoFormat("Closing The Session with Id {0}", this.info.SessionId);
-                DoClose();
-                Tracer.InfoFormat("Closed The Session with Id {0}", this.info.SessionId);
-            }
-            catch(Exception ex)
-            {
-                Tracer.ErrorFormat("Error during session close: {0}", ex);
             }
         }
 



Mime
View raw message