activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r1293361 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk: ./ src/main/csharp/Connection.cs src/main/csharp/Transport/InactivityMonitor.cs src/test/csharp/TempDestinationTest.cs
Date Fri, 24 Feb 2012 17:45:35 GMT
Author: jgomes
Date: Fri Feb 24 17:45:35 2012
New Revision: 1293361

URL: http://svn.apache.org/viewvc?rev=1293361&view=rev
Log:
Merged revision(s) 1293360 from activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x:
Minor logging clean ups.
Cleaned up TempDestinationTest using common function to track connections that are used in
the tests. Added TestConsumeAfterPublishFailsForDestroyedTempDestination.
........

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/   (props changed)
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 24 17:45:35 2012
@@ -1,3 +1,3 @@
-/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x:1082291,1135831,1137081,1171843,1171874,1177390,1177395,1186568,1187123,1238881
+/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x:1082291,1135831,1137081,1171843,1171874,1177390,1177395,1186568,1187123,1238881,1293360
 /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/tags/1.0.0:692591,693525
 /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/tags/1.1.0:788230,788233,790183

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs?rev=1293361&r1=1293360&r2=1293361&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs Fri Feb
24 17:45:35 2012
@@ -910,6 +910,7 @@ namespace Apache.NMS.ActiveMQ
 						}
 					}
 
+					Tracer.Error(message + " : " + cause);
 					OnException(new NMSConnectionException(message, cause));
 				}
 			}

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs?rev=1293361&r1=1293360&r2=1293361&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
Fri Feb 24 17:45:35 2012
@@ -455,7 +455,7 @@ namespace Apache.NMS.ActiveMQ.Transport
 
 			public bool Iterate()
 			{
-				Tracer.DebugFormat("InactivityMonitor[{0}] perparing for another Write Check", parent.instanceId);
+				Tracer.DebugFormat("InactivityMonitor[{0}] preparing for another Write Check", parent.instanceId);
 				if(this.pending.CompareAndSet(true, false) && this.parent.monitorStarted.Value)
 				{
 					try

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs?rev=1293361&r1=1293360&r2=1293361&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs
Fri Feb 24 17:45:35 2012
@@ -32,16 +32,12 @@ namespace Apache.NMS.ActiveMQ.Test
     [TestFixture]
     public class TempDestinationTest : NMSTestSupport
     {
-        private Connection connection;
         private readonly IList connections = ArrayList.Synchronized(new ArrayList());
 
         [SetUp]
         public override void SetUp()
         {
             base.SetUp();
-
-            connection = this.CreateConnection() as Connection;
-            connections.Add(connection);
         }
 
         [TearDown]
@@ -59,17 +55,24 @@ namespace Apache.NMS.ActiveMQ.Test
             }
 
             connections.Clear();
-
             base.TearDown();
         }
 
-        /// <summary>
+		private Connection GetNewConnection()
+		{
+			Connection newConnection = CreateConnection() as Connection;
+			connections.Add(newConnection);
+			return newConnection;
+		}
+
+		/// <summary>
         /// Make sure Temp destination can only be consumed by local connection
         /// </summary>
         [Test]
         public void TestTempDestOnlyConsumedByLocalConn()
         {
-            connection.Start();
+			Connection connection = GetNewConnection();
+			connection.Start();
 
             ISession tempSession = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = tempSession.CreateTemporaryQueue();
@@ -79,8 +82,7 @@ namespace Apache.NMS.ActiveMQ.Test
             producer.Send(message);
 
             // temp destination should not be consume when using another connection
-            Connection otherConnection = CreateConnection() as Connection;
-            connections.Add(otherConnection);
+			Connection otherConnection = GetNewConnection();
             ISession otherSession = otherConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue otherQueue = otherSession.CreateTemporaryQueue();
             IMessageConsumer consumer = otherSession.CreateConsumer(otherQueue);
@@ -111,7 +113,8 @@ namespace Apache.NMS.ActiveMQ.Test
         [Test]
         public void TestTempQueueHoldsMessagesWithConsumers()
         {
-            ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+			Connection connection = GetNewConnection();
+			ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             IQueue queue = session.CreateTemporaryQueue();
             IMessageConsumer consumer = session.CreateConsumer(queue);
             connection.Start();
@@ -134,7 +137,8 @@ namespace Apache.NMS.ActiveMQ.Test
         [Test]
         public void TestTempQueueHoldsMessagesWithoutConsumers()
         {
-            ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+			Connection connection = GetNewConnection();
+			ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             IQueue queue = session.CreateTemporaryQueue();
             IMessageProducer producer = session.CreateProducer(queue);
             producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
@@ -161,7 +165,8 @@ namespace Apache.NMS.ActiveMQ.Test
             int dataSize = 1024;
     
             ArrayList list = new ArrayList(count);
-            ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+			Connection connection = GetNewConnection();
+			ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             IQueue queue = session.CreateTemporaryQueue();
             IMessageProducer producer = session.CreateProducer(queue);
             producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
@@ -193,8 +198,8 @@ namespace Apache.NMS.ActiveMQ.Test
         [Test]
         public void TestPublishFailsForClosedConnection()
         {
-            Connection tempConnection = CreateConnection() as Connection;
-            connections.Add(tempConnection);
+			Connection connection = GetNewConnection();
+			Connection tempConnection = GetNewConnection();
             ISession tempSession = tempConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = tempSession.CreateTemporaryQueue();
 
@@ -234,8 +239,8 @@ namespace Apache.NMS.ActiveMQ.Test
         [Test]
         public void TestPublishFailsForDestoryedTempDestination()
         {
-            Connection tempConnection = CreateConnection() as Connection;
-            connections.Add(tempConnection);
+			Connection connection = GetNewConnection();
+			Connection tempConnection = GetNewConnection();
             ISession tempSession = tempConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = tempSession.CreateTemporaryQueue();
     
@@ -265,18 +270,70 @@ namespace Apache.NMS.ActiveMQ.Test
             catch(NMSException e)
             {
                 Tracer.Debug("Test threw expected exception: " + e.Message);
-                Assert.IsTrue(true, "failed to throw an exception");
             }
         }
-    
-        /// <summary>
+
+		/// <summary>
+		/// Make sure consumers work after a publisher fails to publish to deleted temp destination.
+		/// </summary>
+		[Test]
+		public void TestConsumeAfterPublishFailsForDestroyedTempDestination()
+		{
+			const string msgQueueName = "Test.RequestReply.MsgQueue";
+			Connection consumerConnection = GetNewConnection();
+			ISession consumerSession = consumerConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+			IDestination consumerDestination = consumerSession.GetQueue(msgQueueName);
+			IMessageConsumer consumer = consumerSession.CreateConsumer(consumerDestination);
+
+			consumerConnection.Start();
+
+			// The real test is whether sending a message to a deleted temp queue messes up
+			// the consumers on the same connection.
+			for(int index = 0; index < 25; index++)
+			{
+				Connection producerConnection = GetNewConnection();
+				ISession producerSession = producerConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+				IDestination producerDestination = producerSession.GetQueue(msgQueueName);
+				IMessageProducer producer = producerSession.CreateProducer(producerDestination);
+				IDestination replyDestination = producerSession.CreateTemporaryQueue();
+				IMessageConsumer replyConsumer = producerSession.CreateConsumer(replyDestination);
+
+				producerConnection.Start();
+
+				IMessage sendMsg = producer.CreateTextMessage("Consumer check.");
+				sendMsg.NMSReplyTo = replyDestination;
+
+				producer.Send(sendMsg);
+
+				// Will the following Receive() call fail on the second or subsequent calls?
+				IMessage receiveMsg = consumer.Receive();
+				IMessageProducer replyProducer = consumerSession.CreateProducer(receiveMsg.NMSReplyTo);
+
+				connections.Remove(producerConnection);
+				producerConnection.Close();
+				//Thread.Sleep(2000); // Wait a little bit to let the delete take effect.
+
+				// This message delivery NOT should work since the temp destination was removed by closing
the connection.
+				try
+				{
+					IMessage replyMsg = replyProducer.CreateTextMessage("Reply check.");
+					replyProducer.Send(replyMsg);
+					Assert.Fail("Send should fail since temp destination should not exist anymore.");
+				}
+				catch(NMSException e)
+				{
+					Tracer.Debug("Test threw expected exception: " + e.Message);
+				}
+			}
+		}
+
+		/// <summary>
         /// Test you can't delete a Destination with Active Subscribers
         /// </summary>
         [Test]
         public void TestDeleteDestinationWithSubscribersFails()
         {
-            Connection connection = CreateConnection() as Connection;
-            connections.Add(connection);
+			Connection connection = GetNewConnection();
             ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
             ITemporaryQueue queue = session.CreateTemporaryQueue();
 



Mime
View raw message