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/16 15:14:04 UTC

svn commit: r891244 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/ConnectionFactory.cs test/csharp/NMSConnectionFactoryTest.cs

Author: tabish
Date: Wed Dec 16 14:14:04 2009
New Revision: 891244

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

Allow Prefetch properties to be set on the Connection URI.

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

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs?rev=891244&r1=891243&r2=891244&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs Wed Dec 16 14:14:04 2009
@@ -112,7 +112,9 @@
 			// is that this works with simple Uri as well.
 			URISupport.CompositeData c = URISupport.parseComposite(uri);
 			URISupport.SetProperties(connection, c.Parameters, "connection.");
-            
+
+            URISupport.SetProperties(connection.PrefetchPolicy, c.Parameters, "nms.PrefetchPolicy.");
+
 			connection.ITransport.Start();
 			return connection;
 		}

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs?rev=891244&r1=891243&r2=891244&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs Wed Dec 16 14:14:04 2009
@@ -70,5 +70,55 @@
 				Assert.IsNotNull(connection);
 			}
 		}
-	}
+
+        [Test]
+        public void TestURIForPrefetchHandling()
+        {
+            string uri1 = "activemq:tcp://${activemqhost}:61616" +
+                          "?nms.PrefetchPolicy.queuePrefetch=1" +
+                          "&nms.PrefetchPolicy.queueBrowserPrefetch=2" +
+                          "&nms.PrefetchPolicy.topicPrefetch=3" +
+                          "&nms.PrefetchPolicy.durableTopicPrefetch=4" +
+                          "&nms.PrefetchPolicy.maximumPendingMessageLimit=5";
+
+            string uri2 = "activemq:tcp://${activemqhost}:61616" +
+                          "?nms.PrefetchPolicy.queuePrefetch=112" +
+                          "&nms.PrefetchPolicy.queueBrowserPrefetch=212" +
+                          "&nms.PrefetchPolicy.topicPrefetch=312" +
+                          "&nms.PrefetchPolicy.durableTopicPrefetch=412" +
+                          "&nms.PrefetchPolicy.maximumPendingMessageLimit=512";
+
+            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(1, amqConnection.PrefetchPolicy.QueuePrefetch);
+                Assert.AreEqual(2, amqConnection.PrefetchPolicy.QueueBrowserPrefetch);
+                Assert.AreEqual(3, amqConnection.PrefetchPolicy.TopicPrefetch);
+                Assert.AreEqual(4, amqConnection.PrefetchPolicy.DurableTopicPrefetch);
+                Assert.AreEqual(5, amqConnection.PrefetchPolicy.MaximumPendingMessageLimit);
+            }
+
+            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(112, amqConnection.PrefetchPolicy.QueuePrefetch);
+                Assert.AreEqual(212, amqConnection.PrefetchPolicy.QueueBrowserPrefetch);
+                Assert.AreEqual(312, amqConnection.PrefetchPolicy.TopicPrefetch);
+                Assert.AreEqual(412, amqConnection.PrefetchPolicy.DurableTopicPrefetch);
+                Assert.AreEqual(512, amqConnection.PrefetchPolicy.MaximumPendingMessageLimit);
+            }
+        }
+    }
 }