activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r988584 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/TransactionContext.cs test/csharp/AMQTransactionTestSupport.cs
Date Tue, 24 Aug 2010 15:00:49 GMT
Author: tabish
Date: Tue Aug 24 15:00:49 2010
New Revision: 988584

URL: http://svn.apache.org/viewvc?rev=988584&view=rev
Log:
fix for: https://issues.apache.org/activemq/browse/AMQNET-275

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/TransactionContext.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/AMQTransactionTestSupport.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=988584&r1=988583&r2=988584&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 Aug 24 15:00:49 2010
@@ -83,58 +83,54 @@ namespace Apache.NMS.ActiveMQ
         
         public void Rollback()
         {
-            if(!InTransaction)
+            if(InTransaction)
             {
-                throw new NMSException("Invliad State: Not Currently in a Transaction");
-            }
-
-            this.BeforeEnd();
-
-            if(Tracer.IsDebugEnabled)
-            {
-                Tracer.Debug("Rollback: "  + this.transactionId +
-                             " syncCount: " +
-                             (synchronizations != null ? synchronizations.Count : 0));
+                this.BeforeEnd();
+    
+                if(Tracer.IsDebugEnabled)
+                {
+                    Tracer.Debug("Rollback: "  + this.transactionId +
+                                 " syncCount: " +
+                                 (synchronizations != null ? synchronizations.Count : 0));
+                }
+    
+                TransactionInfo info = new TransactionInfo();
+                info.ConnectionId = this.session.Connection.ConnectionId;
+                info.TransactionId = transactionId;
+                info.Type = (int) TransactionType.Rollback;
+                
+                this.transactionId = null;
+                this.session.Connection.SyncRequest(info);
+    
+                this.AfterRollback();
+                this.synchronizations.Clear();
             }
-
-            TransactionInfo info = new TransactionInfo();
-            info.ConnectionId = this.session.Connection.ConnectionId;
-            info.TransactionId = transactionId;
-            info.Type = (int) TransactionType.Rollback;
-            
-            this.transactionId = null;
-            this.session.Connection.SyncRequest(info);
-
-            this.AfterRollback();
-            this.synchronizations.Clear();
         }
         
         public void Commit()
         {
-            if(!InTransaction)
+            if(InTransaction)
             {
-                throw new NMSException("Invliad State: Not Currently in a Transaction");
-            }
-
-            this.BeforeEnd();
-
-            if(Tracer.IsDebugEnabled)
-            {
-                Tracer.Debug("Commit: "  + this.transactionId +
-                             " syncCount: " +
-                             (synchronizations != null ? synchronizations.Count : 0));
+                this.BeforeEnd();
+    
+                if(Tracer.IsDebugEnabled)
+                {
+                    Tracer.Debug("Commit: "  + this.transactionId +
+                                 " syncCount: " +
+                                 (synchronizations != null ? synchronizations.Count : 0));
+                }
+    
+                TransactionInfo info = new TransactionInfo();
+                info.ConnectionId = this.session.Connection.ConnectionId;
+                info.TransactionId = transactionId;
+                info.Type = (int) TransactionType.CommitOnePhase;
+                
+                this.transactionId = null;
+                this.session.Connection.SyncRequest(info);
+                
+                this.AfterCommit();
+                this.synchronizations.Clear();
             }
-
-            TransactionInfo info = new TransactionInfo();
-            info.ConnectionId = this.session.Connection.ConnectionId;
-            info.TransactionId = transactionId;
-            info.Type = (int) TransactionType.CommitOnePhase;
-            
-            this.transactionId = null;
-            this.session.Connection.SyncRequest(info);
-            
-            this.AfterCommit();
-            this.synchronizations.Clear();
         }
 
         internal void BeforeEnd()

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/AMQTransactionTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/AMQTransactionTestSupport.cs?rev=988584&r1=988583&r2=988584&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/AMQTransactionTestSupport.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/AMQTransactionTestSupport.cs
Tue Aug 24 15:00:49 2010
@@ -108,6 +108,18 @@ namespace Apache.NMS.ActiveMQ.Test
         }
 
         [Test]
+        public void TestSessionCommitedWithoutReceivingMessage()
+        {
+            Assert.IsTrue(session.Transacted);
+
+            IMessage message = consumer.Receive(new TimeSpan(0, 0, 0, 0, 100));
+            Assert.IsNull(message);
+            session.Commit();
+
+            Assert.Pass("When getting here. It is ok");
+        }
+
+        [Test]
         public void TestSendReceiveTransactedBatches()
         {
             ITextMessage message = session.CreateTextMessage("Batch IMessage");
@@ -605,6 +617,5 @@ namespace Apache.NMS.ActiveMQ.Test
 
             Assert.IsFalse(ackMessages.Count < MESSAGE_COUNT);
         }
-
     }
 }



Mime
View raw message