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/17 19:57:52 UTC

svn commit: r891839 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src: main/csharp/ConnectionFactory.cs test/csharp/AMQRedeliveryPolicyTest.cs

Author: tabish
Date: Thu Dec 17 18:57:52 2009
New Revision: 891839

URL: http://svn.apache.org/viewvc?rev=891839&view=rev
Log:
Allow RedeliveryPolicy attributes to be specified from the URI via nms.RedeliveryPolicy.* notation.

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

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs?rev=891839&r1=891838&r2=891839&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs Thu Dec 17 18:57:52 2009
@@ -114,6 +114,7 @@
 			URISupport.SetProperties(connection, c.Parameters, "connection.");
 
             URISupport.SetProperties(connection.PrefetchPolicy, c.Parameters, "nms.PrefetchPolicy.");
+            URISupport.SetProperties(connection.RedeliveryPolicy, c.Parameters, "nms.RedeliveryPolicy.");
 
 			connection.ITransport.Start();
 			return connection;

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/AMQRedeliveryPolicyTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/AMQRedeliveryPolicyTest.cs?rev=891839&r1=891838&r2=891839&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/AMQRedeliveryPolicyTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/AMQRedeliveryPolicyTest.cs Thu Dec 17 18:57:52 2009
@@ -297,5 +297,56 @@
             }
         }
 
+        [Test]
+        public void TestURIForRedeliverPolicyHandling()
+        {
+            string uri1 = "activemq:tcp://${activemqhost}:61616" +
+                          "?nms.RedeliveryPolicy.BackOffMultiplier=10" +
+                          "&nms.RedeliveryPolicy.InitialRedeliveryDelay=2000" +
+                          "&nms.RedeliveryPolicy.UseExponentialBackOff=true" +
+                          "&nms.RedeliveryPolicy.UseCollisionAvoidance=true" +
+                          "&nms.RedeliveryPolicy.CollisionAvoidancePercent=20";
+
+            string uri2 = "activemq:tcp://${activemqhost}:61616" +
+                          "?nms.RedeliveryPolicy.backOffMultiplier=50" +
+                          "&nms.RedeliveryPolicy.initialRedeliveryDelay=4000" +
+                          "&nms.RedeliveryPolicy.useExponentialBackOff=false" +
+                          "&nms.RedeliveryPolicy.useCollisionAvoidance=false" +
+                          "&nms.RedeliveryPolicy.collisionAvoidancePercent=10";
+
+            NMSConnectionFactory factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(uri1));
+
+            Assert.IsNotNull(factory);
+            Assert.IsNotNull(factory.ConnectionFactory);
+            using(IConnection connection = factory.CreateConnection("", ""))
+            {
+                Assert.IsNotNull(connection);
+
+                Connection amqConnection = connection as Connection;
+
+                Assert.AreEqual(10, amqConnection.RedeliveryPolicy.BackOffMultiplier);
+                Assert.AreEqual(2000, amqConnection.RedeliveryPolicy.InitialRedeliveryDelay);
+                Assert.AreEqual(true, amqConnection.RedeliveryPolicy.UseExponentialBackOff);
+                Assert.AreEqual(true, amqConnection.RedeliveryPolicy.UseCollisionAvoidance);
+                Assert.AreEqual(20, amqConnection.RedeliveryPolicy.CollisionAvoidancePercent);
+            }
+
+            factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(uri2));
+
+            Assert.IsNotNull(factory);
+            Assert.IsNotNull(factory.ConnectionFactory);
+            using(IConnection connection = factory.CreateConnection("", ""))
+            {
+                Assert.IsNotNull(connection);
+
+                Connection amqConnection = connection as Connection;
+                Assert.AreEqual(50, amqConnection.RedeliveryPolicy.BackOffMultiplier);
+                Assert.AreEqual(4000, amqConnection.RedeliveryPolicy.InitialRedeliveryDelay);
+                Assert.AreEqual(false, amqConnection.RedeliveryPolicy.UseExponentialBackOff);
+                Assert.AreEqual(false, amqConnection.RedeliveryPolicy.UseCollisionAvoidance);
+                Assert.AreEqual(10, amqConnection.RedeliveryPolicy.CollisionAvoidancePercent);
+            }
+        }
+
     }
 }