activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r884195 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src: main/csharp/MessageConsumer.cs test/csharp/IndividualAckTest.cs
Date Wed, 25 Nov 2009 16:54:33 GMT
Author: tabish
Date: Wed Nov 25 16:54:33 2009
New Revision: 884195

URL: http://svn.apache.org/viewvc?rev=884195&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQNET-214

Fix the individual ack callback so that it searches the entire list of dispatched messages
for the one to ack.  Adds the users test case to the Individual Ack tests.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/MessageConsumer.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/IndividualAckTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/MessageConsumer.cs?rev=884195&r1=884194&r2=884195&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/MessageConsumer.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/MessageConsumer.cs
Wed Nov 25 16:54:33 2009
@@ -341,10 +341,14 @@
 						this.dispatchedMessages.Remove(originalDispatch);
 						break;
 					}
-
-					return;
 				}
 			}
+			
+			if(dispatch == null) 
+			{
+				Tracer.DebugFormat("Attempt to Ack MessageId[{0}] failed because the original dispatch
is not in the Dispatch List", message.MessageId);
+				return;
+			}
 
 			MessageAck ack = new MessageAck();
 
@@ -354,6 +358,7 @@
 			ack.LastMessageId = dispatch.Message.MessageId;
 			ack.MessageCount = 1;
 
+			Tracer.Debug("Sending Individual Ack for MessageId: " + ack.LastMessageId.ToString());
 			this.session.Connection.Oneway(ack);
 		}
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/IndividualAckTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/IndividualAckTest.cs?rev=884195&r1=884194&r2=884195&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/IndividualAckTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/IndividualAckTest.cs
Wed Nov 25 16:54:33 2009
@@ -139,5 +139,49 @@
             session.Close();
         }
         
+        [Test]
+	    public void TestIndividualAcknowledgeMultiMessages_AcknowledgeFirstTest()
+		{
+            ISession session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
+	
+            // Push 2 messages to queue
+            ITemporaryQueue queue = session.CreateTemporaryQueue();
+            IMessageProducer producer = session.CreateProducer(queue);
+
+            ITextMessage msg = session.CreateTextMessage("test 1");
+            producer.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, TimeSpan.MinValue);
           
+			msg = session.CreateTextMessage("test 2");		
+            producer.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, TimeSpan.MinValue);
+            producer.Close();
+
+            IMessageConsumer consumer = session.CreateConsumer(queue);
+			
+            // Read the first message
+            ITextMessage fetchedMessage1 = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(2000));
+            Assert.IsNotNull(fetchedMessage1);
+            Assert.AreEqual("test 1", fetchedMessage1.Text);
+            
+			// Read the second message
+			ITextMessage fetchedMessage2 = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(2000));
+            Assert.IsNotNull(fetchedMessage2);
+            Assert.AreEqual("test 2", fetchedMessage2.Text);
+
+            // Acknowledge first message
+            fetchedMessage1.Acknowledge();
+
+            consumer.Close();
+
+            // Read first message a second time
+            consumer = session.CreateConsumer(queue);
+            fetchedMessage1 = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(2000));
+            Assert.IsNotNull(fetchedMessage1);
+            Assert.AreEqual("test 2", fetchedMessage1.Text);
+
+            // Try to read second message a second time
+            fetchedMessage2 = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(2000));
+            Assert.IsNull(fetchedMessage2);
+            consumer.Close();
+	    }
+		
     }
 }



Mime
View raw message