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 2014/12/19 16:56:52 UTC

svn commit: r1646782 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk: ./ src/main/csharp/ src/test/csharp/

Author: tabish
Date: Fri Dec 19 15:56:51 2014
New Revision: 1646782

URL: http://svn.apache.org/r1646782
Log:
https://issues.apache.org/jira/browse/AMQNET-496

Default to priority support off and when it is enabled swith to individual ack mode to prevent unmatched ack errors.

Added:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/BatchedMessagePriorityConsumerTest.cs   (with props)
Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj

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=1646782&r1=1646781&r2=1646782&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 Dec 19 15:56:51 2014
@@ -49,7 +49,7 @@ namespace Apache.NMS.ActiveMQ
         private bool sendAcksAsync = false;
         private bool dispatchAsync = true;
         private int producerWindowSize = 0;
-        private bool messagePrioritySupported = true;
+        private bool messagePrioritySupported = false;
         private bool watchTopicAdviosires = true;
         private bool optimizeAcknowledge;
         private long optimizeAcknowledgeTimeOut = 300;

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=1646782&r1=1646781&r2=1646782&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 Fri Dec 19 15:56:51 2014
@@ -50,7 +50,7 @@ namespace Apache.NMS.ActiveMQ
 		private int producerWindowSize = 0;
 		private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
 		private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout;
-		private bool messagePrioritySupported = true;
+		private bool messagePrioritySupported = false;
         private bool watchTopicAdvisories = true;
     	private bool optimizeAcknowledge;
     	private long optimizeAcknowledgeTimeOut = 300;

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs?rev=1646782&r1=1646781&r2=1646782&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs Fri Dec 19 15:56:51 2014
@@ -170,7 +170,9 @@ namespace Apache.NMS.ActiveMQ
             this.info.OptimizedAcknowledge = this.optimizeAcknowledge;
             this.failoverRedeliveryWaitPeriod = session.Connection.ConsumerFailoverRedeliveryWaitPeriod;
             this.nonBlockingRedelivery = session.Connection.NonBlockingRedelivery;
-            this.transactedIndividualAck = session.Connection.TransactedIndividualAck || this.nonBlockingRedelivery;
+            this.transactedIndividualAck = session.Connection.TransactedIndividualAck || 
+                                           session.Connection.MessagePrioritySupported ||
+                                           this.nonBlockingRedelivery;
         }
 
         ~MessageConsumer()

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/BatchedMessagePriorityConsumerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/BatchedMessagePriorityConsumerTest.cs?rev=1646782&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/BatchedMessagePriorityConsumerTest.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/BatchedMessagePriorityConsumerTest.cs Fri Dec 19 15:56:51 2014
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+using NUnit.Framework;
+using Apache.NMS.ActiveMQ.Commands;
+using Apache.NMS;
+using Apache.NMS.Util;
+using Apache.NMS.Test;
+
+namespace Apache.NMS.ActiveMQ.Test
+{
+    [TestFixture]
+    public class BatchedMessagePriorityConsumerTest : NMSTestSupport
+    {
+        protected static string DESTINATION_NAME = "queue://TEST.BatchedMessagePriorityConsumerTest";
+        protected static string TEST_CLIENT_ID = "BatchedMessagePriorityConsumerTestID";
+
+        [Test]
+        public void TestBatchWithLowPriorityFirstAndClientSupport() 
+        {
+            DoTestBatchWithLowPriorityFirst(true);
+        }
+
+        [Test]
+        public void testBatchWithLowPriorityFirstAndClientSupportOff() 
+        {
+            DoTestBatchWithLowPriorityFirst(false);
+        }
+
+        protected void DoTestBatchWithLowPriorityFirst(bool clientPrioritySupport)
+        {
+            using (Connection connection = (Connection) CreateConnection(TEST_CLIENT_ID))
+            {
+                connection.Start();
+                connection.MessagePrioritySupported = clientPrioritySupport;
+
+                using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                using (IQueue queue = (IQueue) SessionUtil.GetDestination(session, DESTINATION_NAME))
+                {
+                    using (IMessageProducer producer = session.CreateProducer(queue))
+                    {
+                        producer.Priority = MsgPriority.Lowest;
+                        producer.Send(session.CreateTextMessage("1"));
+                        producer.Send(session.CreateTextMessage("2"));
+                    }
+
+                    using (IMessageProducer producer = session.CreateProducer(queue))
+                    {
+                        producer.Priority = MsgPriority.Highest;
+                        producer.Send(session.CreateTextMessage("3"));
+                        producer.Send(session.CreateTextMessage("4"));
+                        producer.Send(session.CreateTextMessage("5"));
+                    }
+                }
+
+                using (ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+                using (IQueue queue = (IQueue) SessionUtil.GetDestination(session, DESTINATION_NAME))
+                using (IMessageConsumer consumer = session.CreateConsumer(queue))
+                {
+                    for (int i = 0; i < 5; i++) 
+                    {
+                        IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(4000));
+                        Tracer.InfoFormat("MessageID: {0}", message.NMSMessageId);
+                    }
+
+                    session.Commit();
+                }
+
+                using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                using (IQueue queue = SessionUtil.GetDestination(session, DESTINATION_NAME) as IQueue)
+                using (IMessageConsumer consumer = session.CreateConsumer(queue))
+                {
+                    // should be nothing left
+                    IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
+                    Assert.IsNull(message, "Should be no messages in the Queue");
+                }    
+            }
+        }
+    }
+}
+

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/BatchedMessagePriorityConsumerTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj?rev=1646782&r1=1646781&r2=1646782&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj Fri Dec 19 15:56:51 2014
@@ -141,6 +141,7 @@
     <Compile Include="src\test\csharp\VirtualTopicTest.cs" />
     <Compile Include="src\test\csharp\ZeroPrefetchConsumerTest.cs" />
     <Compile Include="src\test\csharp\OpenWire\BaseDataStreamMarshallerTest.cs" />
+    <Compile Include="src\test\csharp\BatchedMessagePriorityConsumerTest.cs" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="nmsprovider-test.config">