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 2009/12/18 17:31:50 UTC
svn commit: r892306 -
/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/RollbackRedeliveryTest.cs
Author: tabish
Date: Fri Dec 18 16:31:49 2009
New Revision: 892306
URL: http://svn.apache.org/viewvc?rev=892306&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQNET-220
Updated RedeliveryRollbackTests to check for the case where max redeliveries is reached. Added test for single session and multiple session consumption.
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/RollbackRedeliveryTest.cs
Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/RollbackRedeliveryTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/RollbackRedeliveryTest.cs?rev=892306&r1=892305&r2=892306&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/RollbackRedeliveryTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/RollbackRedeliveryTest.cs Fri Dec 18 16:31:49 2009
@@ -214,6 +214,97 @@
}
[Test]
+ public void TestMessageRedelivedMaxRedeliveriesTimesSingleSession()
+ {
+ connection.RedeliveryPolicy.MaximumRedeliveries = 15;
+ connection.RedeliveryPolicy.UseCollisionAvoidance = false;
+ connection.RedeliveryPolicy.UseExponentialBackOff = false;
+
+ connection.Start();
+
+ PopulateDestination(1, destinationName);
+
+ // Consume messages and Rollback transactions
+ {
+ int received = 0;
+ ISession session = connection.CreateSession(AcknowledgementMode.Transactional);
+ IDestination destination = session.GetQueue(destinationName);
+
+ IMessageConsumer consumer = session.CreateConsumer(destination);
+ ITextMessage msg = null;
+
+ while(received <= connection.RedeliveryPolicy.MaximumRedeliveries)
+ {
+ msg = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(6000000));
+ Assert.IsNotNull(msg);
+
+ if(received > 0)
+ {
+ Assert.IsTrue(msg.NMSRedelivered);
+ Assert.AreEqual(received, msg.Properties.GetLong("NMSXDeliveryCount") - 1);
+ }
+
+ Interlocked.Increment(ref received);
+
+ session.Rollback();
+ }
+
+ msg = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(6000));
+ Assert.IsNull(msg);
+
+ session.Close();
+ }
+ }
+
+ [Test]
+ public void TestMessageRedelivedMaxRedeliveriesTimesMultipleSessions()
+ {
+ connection.RedeliveryPolicy.MaximumRedeliveries = 15;
+ connection.RedeliveryPolicy.UseCollisionAvoidance = false;
+ connection.RedeliveryPolicy.UseExponentialBackOff = false;
+
+ connection.Start();
+
+ PopulateDestination(1, destinationName);
+
+ // Consume messages and Rollback transactions
+ {
+ int received = 0;
+
+ ISession session = null;
+ IDestination destination = null;
+ IMessageConsumer consumer = null;
+ ITextMessage msg = null;
+
+ while(received <= connection.RedeliveryPolicy.MaximumRedeliveries)
+ {
+ session = connection.CreateSession(AcknowledgementMode.Transactional);
+ destination = session.GetQueue(destinationName);
+ consumer = session.CreateConsumer(destination);
+ msg = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(6000000));
+ Assert.IsNotNull(msg);
+
+ if(received > 0)
+ {
+ Assert.IsTrue(msg.NMSRedelivered);
+ Assert.AreEqual(received, msg.Properties.GetLong("NMSXDeliveryCount") - 1);
+ }
+
+ Interlocked.Increment(ref received);
+
+ session.Rollback();
+ session.Close();
+ }
+
+ session = connection.CreateSession(AcknowledgementMode.Transactional);
+ destination = session.GetQueue(destinationName);
+ consumer = session.CreateConsumer(destination);
+ msg = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(6000));
+ Assert.IsNull(msg);
+ }
+ }
+
+ [Test]
public void TestValidateRedeliveryCountOnRollback()
{
const int numMessages = 1;