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/04/27 15:47:38 UTC
svn commit: r1097109 - in
/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp:
NetTxSession.cs Session.cs
Author: tabish
Date: Wed Apr 27 13:47:38 2011
New Revision: 1097109
URL: http://svn.apache.org/viewvc?rev=1097109&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/trunk/src/main/csharp/NetTxSession.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxSession.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxSession.cs?rev=1097109&r1=1097108&r2=1097109&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxSession.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxSession.cs Wed Apr 27 13:47: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/trunk/src/main/csharp/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs?rev=1097109&r1=1097108&r2=1097109&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs Wed Apr 27 13:47: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;
@@ -291,38 +291,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);
}
}