Author: tabish
Date: Tue Dec 14 16:24:24 2010
New Revision: 1049145
URL: http://svn.apache.org/viewvc?rev=1049145&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQNET-296
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/QueueBrowser.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/SimplePriorityMessageDispatchChannel.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/QueueBrowserTests.cs
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/QueueBrowser.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/QueueBrowser.cs?rev=1049145&r1=1049144&r2=1049145&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/QueueBrowser.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/QueueBrowser.cs
Tue Dec 14 16:24:24 2010
@@ -33,7 +33,7 @@ namespace Apache.NMS.ActiveMQ
private bool disposed;
private bool closed;
private readonly ConsumerId consumerId;
- private readonly Atomic<bool> browseDone = new
Atomic<bool>(true);
+ private readonly Atomic<bool> browseDone = new
Atomic<bool>(false);
private readonly bool dispatchAsync;
private readonly object semaphore = new object();
private readonly object myLock = new object();
@@ -168,16 +168,19 @@ namespace Apache.NMS.ActiveMQ
{
if(consumer == null)
{
+ Tracer.Debug("QB-MoveNext: Consumer was null,
returning false.");
return false;
}
if(consumer.UnconsumedMessageCount > 0)
{
+ Tracer.Debug("QB-MoveNext: Consumer has unconsumed
Messages, returning true.");
return true;
}
if(browseDone.Value || !session.Started)
{
+ Tracer.Debug("QB-MoveNext: Browse done or session not
started, return false.");
DestroyConsumer();
return false;
}
@@ -316,10 +319,12 @@ namespace Apache.NMS.ActiveMQ
{
if(md.Message == null)
{
+ Tracer.Debug("QueueBrowser recieved Null Message in
Dispatch, Browse Done.");
parent.browseDone.Value = true;
}
else
{
+ Tracer.Debug("QueueBrowser dispatching next Message to
Consumer.");
base.Dispatch(md);
}
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/SimplePriorityMessageDispatchChannel.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/SimplePriorityMessageDispatchChannel.cs?rev=1049145&r1=1049144&r2=1049145&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/SimplePriorityMessageDispatchChannel.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/SimplePriorityMessageDispatchChannel.cs
Tue Dec 14 16:24:24 2010
@@ -246,9 +246,9 @@ namespace Apache.NMS.ActiveMQ.Util
return result;
}
- protected int getPriority(MessageDispatch message)
+ protected int GetPriority(MessageDispatch message)
{
- int priority = (int) NMSConstants.defaultPriority;
+ int priority = (int) MsgPriority.Lowest;
if(message.Message != null)
{
@@ -261,7 +261,7 @@ namespace Apache.NMS.ActiveMQ.Util
protected LinkedList<MessageDispatch> GetList(MessageDispatch md)
{
- return channels[getPriority(md)];
+ return channels[GetPriority(md)];
}
private MessageDispatch RemoveFirst()
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/QueueBrowserTests.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/QueueBrowserTests.cs?rev=1049145&r1=1049144&r2=1049145&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/QueueBrowserTests.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/QueueBrowserTests.cs
Tue Dec 14 16:24:24 2010
@@ -16,7 +16,9 @@
*/
using System;
+using System.Threading;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
using Apache.NMS.ActiveMQ.Commands;
using Apache.NMS.Test;
@@ -112,6 +114,37 @@ namespace Apache.NMS.ActiveMQ.Test
}
}
+ [Test]
+ public void TestBroserIteratively()
+ {
+ using (IConnection connection = CreateConnection())
+ using (ISession session =
connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ connection.Start();
+
+ IQueue queue = session.CreateTemporaryQueue();
+ // enqueue a message
+ using (IMessageProducer producer =
session.CreateProducer(queue))
+ {
+ IMessage message = producer.CreateMessage();
+ producer.Send(message);
+ }
+
+ Thread.Sleep(2000);
+
+ // browse queue several times
+ for (int j = 0; j < 1000; j++)
+ {
+ using(QueueBrowser browser = session.CreateBrowser(queue)
as QueueBrowser)
+ {
+ Tracer.DebugFormat("Running Iterative QueueBrowser
sample #{0}", j);
+ IEnumerator enumeration = browser.GetEnumerator();
+ Assert.IsTrue(enumeration.MoveNext(), "should have
received the second message");
+ }
+ }
+ }
+ }
+
[Test]
public void TestBrowseReceive()
{