activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1127627 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/MessageConsumer.cs test/csharp/MessageConsumerTest.cs
Date Wed, 25 May 2011 18:50:53 GMT
Author: tabish
Date: Wed May 25 18:50:53 2011
New Revision: 1127627

URL: http://svn.apache.org/viewvc?rev=1127627&view=rev
Log:
Fix for: https://issues.apache.org/jira/browse/AMQNET-328

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs?rev=1127627&r1=1127626&r2=1127627&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
Wed May 25 18:50:53 2011
@@ -781,7 +781,11 @@ namespace Apache.NMS.ActiveMQ
                         this.session.TransactionContext.SyncRoot.ReleaseMutex();
                         this.session.TransactionContext.DtcWaitHandle.WaitOne();        
               
                     }
-                }
+                    else
+                    {
+                        this.session.TransactionContext.SyncRoot.ReleaseMutex();
+                    }
+                }                
 
 			    lock(this.dispatchedMessages)
 				{

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs?rev=1127627&r1=1127626&r2=1127627&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs
Wed May 25 18:50:53 2011
@@ -38,6 +38,47 @@ namespace Apache.NMS.ActiveMQ.Test
         protected static string TEST_CLIENT_ID = "MessageConsumerTestClientId";
 
         [Test]
+        public void ConsumeInTwoThreads()
+        {
+            ParameterizedThreadStart threadStart =
+                delegate(object o)
+                {
+                    IMessageConsumer consumer = (IMessageConsumer)o;
+                    IMessage message = consumer.Receive(TimeSpan.FromSeconds(2));
+                    Assert.IsNotNull(message);
+                };
+
+            using (IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            {
+                connection.Start();
+                using (ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+                {
+                    IQueue queue = SessionUtil.GetDestination(session, DESTINATION_NAME)
as IQueue;
+
+                    // enqueue 2 messages
+                    using (IMessageConsumer consumer = session.CreateConsumer(queue))
+                    using (IMessageProducer producer = session.CreateProducer(queue))
+                    {
+                        producer.DeliveryMode = MsgDeliveryMode.Persistent;
+                        producer.Send(producer.CreateMessage());
+                        producer.Send(producer.CreateMessage());
+                        session.Commit();
+
+                        // receive first using a dedicated thread. This works
+                        Thread thread = new Thread(threadStart);
+                        thread.Start(consumer);
+                        thread.Join();
+                        session.Commit();
+
+                        // receive second using main thread. This FAILS
+                        IMessage message = consumer.Receive(TimeSpan.FromSeconds(2)); //
throws System.Threading.AbandonedMutexException
+                        Assert.IsNotNull(message);
+                        session.Commit();
+                    }
+                }
+            }
+        }
+        [Test]
         public void TestReceiveIgnoreExpirationMessage(
             [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
                 AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]



Mime
View raw message