activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: Multiple consumers not working with 1.6.2
Date Thu, 30 Jan 2014 20:52:59 GMT
On 01/30/2014 03:45 PM, jaklug wrote:
> 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.
>
Did you try to set the prefetch via the connectionFactory PrefetchPolicy 
property and see if that has any effect?

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Mime
View raw message