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.
diff --git a/src/main/csharp/Connection.cs b/src/main/csharp/Connection.cs
index 242a3cb..a4a5247 100755
--- a/src/main/csharp/Connection.cs
+++ b/src/main/csharp/Connection.cs
@@ -49,7 +49,7 @@
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;
diff --git a/src/main/csharp/ConnectionFactory.cs b/src/main/csharp/ConnectionFactory.cs
index c774ff9..623707f 100755
--- a/src/main/csharp/ConnectionFactory.cs
+++ b/src/main/csharp/ConnectionFactory.cs
@@ -50,7 +50,7 @@
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;
diff --git a/src/main/csharp/MessageConsumer.cs b/src/main/csharp/MessageConsumer.cs
index 9b03735..647a272 100755
--- a/src/main/csharp/MessageConsumer.cs
+++ b/src/main/csharp/MessageConsumer.cs
@@ -170,7 +170,9 @@
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()
diff --git a/src/test/csharp/BatchedMessagePriorityConsumerTest.cs b/src/test/csharp/BatchedMessagePriorityConsumerTest.cs
new file mode 100644
index 0000000..0330e8c
--- /dev/null
+++ b/src/test/csharp/BatchedMessagePriorityConsumerTest.cs
@@ -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");
+ }
+ }
+ }
+ }
+}
+
diff --git a/vs2008-activemq-test.csproj b/vs2008-activemq-test.csproj
index 00753b4..88c55a0 100644
--- a/vs2008-activemq-test.csproj
+++ b/vs2008-activemq-test.csproj
@@ -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">