I'm using the Apache.NMS driver 1.6.2. I want to have multiple consumers
receive message from a queue either in a round-robin fashion or based on the
prefetch value. Regardless of what I set for the delivery policy or the
prefetch value, I can only get one consumer to receive messages. Here is my
consumer code:
const string _queue =
"test.RawEventsQueue?consumer.prefetchSize=1";
const string _connString =
"activemq:failover:(tcp://gzdv-035:61616,tcp://activemq2:61616)";
System.Uri connecturi;
IConnection connection;
ISession session;
IMessageConsumer consumer;
MessageListener receiveMessageListener;
connecturi = new Uri(_connString);
Console.WriteLine("Cconnecting to " + connecturi);
IConnectionFactory factory = new
NMSConnectionFactory(_connString);
connection = factory.CreateConnection();
connection.Start();
session =
connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
var destination = session.GetQueue(_queue);
consumer = session.CreateConsumer(destination);
receiveMessageListener = new MessageListener(OnMessage);
consumer.Listener += receiveMessageListener;
My event handler:
public static void OnMessage(IMessage imessage)
{
Console.WriteLine("Received message");
imessage.Acknowledge();
}
I've tried different values for prefetch. I've also tried modifying the
code to use consumer.Receive(timeout). Even with this approach I only have
one consumer receiving messages. Can you please tell me what I'm doing
wrong? Is this a bug? Seems like this should work without much effort.
--
View this message in context:
http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.