You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by jaklug <ja...@hotmail.com> on 2014/01/30 21:45:09 UTC
Multiple consumers not working with 1.6.2
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.
Re: Multiple consumers not working with 1.6.2
Posted by artnaseef <ar...@artnaseef.com>.
This might help:
http://activemq.2283324.n4.nabble.com/prefetch-size-variations-with-nms-connections-td4668250.html
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677140.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: Multiple consumers not working with 1.6.2
Posted by Timothy Bish <ta...@gmail.com>.
On 01/30/2014 07:09 PM, jaklug wrote:
> I looked at it in the debugger and while it doesn't appear to be set, the
> ActiveMQ management UI (hawtio) shows the consumer with the prefetch size I
> set in the consumer app. I can send you my sample console app, but it's
> really simple and based on most of the samples that are out there today.
> Can you point me to a sample that does what I want, or is there a
> server-side setting/policy that needs to be applied? Right now I'm using
> ActiveMQ 5.9 with whatever settings come on a vanilla install, except I
> set-up a cluster with mirroring. Thanks!
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677131.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Have a look at the unit tests for NMS.ActiveMQ they are very
informative. You need to download the src zip to see them
--
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/
RE: Multiple consumers not working with 1.6.2
Posted by jaklug <ja...@hotmail.com>.
I looked at it in the debugger and while it doesn't appear to be set, the
ActiveMQ management UI (hawtio) shows the consumer with the prefetch size I
set in the consumer app. I can send you my sample console app, but it's
really simple and based on most of the samples that are out there today.
Can you point me to a sample that does what I want, or is there a
server-side setting/policy that needs to be applied? Right now I'm using
ActiveMQ 5.9 with whatever settings come on a vanilla install, except I
set-up a cluster with mirroring. Thanks!
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677131.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: Multiple consumers not working with 1.6.2
Posted by Timothy Bish <ta...@gmail.com>.
On 01/30/2014 04:04 PM, jaklug wrote:
> Yes, I tried this connection string:
>
>
>
> const string _connString =
> "activemq:failover:(tcp://activemq1:61616,tcp://activemq2:61616)?nms.prefetc
> hPolicy.queuePrefetch=1";
>
>
>
> Any other suggestions?
>
> _____
>
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-
> 6-2-tp4677078p4677079.html
>
> To unsubscribe from Multiple consumers not working with 1.6.2, click here
> <http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=unsubs
> cribe_by_code&node=4677078&code=amFrbHVnQGhvdG1haWwuY29tfDQ2NzcwNzh8LTExMjkw
> MDk2NQ==> .
>
> <http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=macro_
> viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.Bas
> icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.templat
> e.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant
> _emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> NAML
>
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677084.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Run the debugger and see if you option is set correctly.
Create a unit test to reproduce if possible.
--
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/
RE: Multiple consumers not working with 1.6.2
Posted by jaklug <ja...@hotmail.com>.
Yes, I tried this connection string:
const string _connString =
"activemq:failover:(tcp://activemq1:61616,tcp://activemq2:61616)?nms.prefetc
hPolicy.queuePrefetch=1";
Any other suggestions?
_____
If you reply to this email, your message will be added to the discussion
below:
http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-
6-2-tp4677078p4677079.html
To unsubscribe from Multiple consumers not working with 1.6.2, click here
<http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=unsubs
cribe_by_code&node=4677078&code=amFrbHVnQGhvdG1haWwuY29tfDQ2NzcwNzh8LTExMjkw
MDk2NQ==> .
<http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=macro_
viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.Bas
icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.templat
e.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant
_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> NAML
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677084.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: Multiple consumers not working with 1.6.2
Posted by Timothy Bish <ta...@gmail.com>.
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/
RE: Multiple consumers not working with 1.6.2
Posted by artnaseef <ar...@artnaseef.com>.
No, there's no way to have more than one - that's the point of a JMSXGroup -
to force only one consumer.
If there's a reason removing the setting from the producer is problematic,
you could look to remove the header as the message comes into the broker. I
believe it's possible to intercept messages with camel in the latest
releases. Otherwise, a broker filter could do the job. I would need to
research if there's an existing way.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677277.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
RE: Multiple consumers not working with 1.6.2
Posted by jaklug <ja...@hotmail.com>.
Thanks for the help. It turns out that your suggestion to look at jmsxgroups is what did it. I requested the code for the producing application and found that it was putting a group id on all the messages. So, a follow-up question – is it possible to have multiple consumers listening for messages in the same group?
Thank you,
Joe
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677276.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: Multiple consumers not working with 1.6.2
Posted by artnaseef <ar...@artnaseef.com>.
I understand your looking to solve this. My advice was not specific enough.
In the webconsole, or jmx client, is it possible to see mbeans for all of the application consumers? And, can you check the message counts for each to confirm the broker-side of what you see?
The use case of multiple consumers has certainly been tested and expected to work.
A couple of things that could thwart you - jmsxgroups and exclusive consumers. Let me know if you need details on those and I will help there.
My intent is to move your diagnostic effort forward at least a little. Hope this helps.
If you are fairly convinced there is a bug, a minimal use case that reproduces the problem would help track it down.
Sorry for confusion.
Sent from my iPhone
> On Jan 30, 2014, at 11:02 PM, "jaklug [via ActiveMQ]" <ml...@n4.nabble.com> wrote:
>
> Artnaseef,
>
>
>
> Messages are NOT being dispatched to each consumer. All the consumers appear in the webconsole, but only the first consumer to connect actually receives messages. I looked at the unit tests, but other than to get the syntax of the prefetch value, they aren’t very useful for this use case. Hasn’t anybody out there implemented a multiple consumer setup like this before? Somebody must have an example of a client that, if I started two instances of it, both would receive messages. I also looked at the link you sent, and I had already tried/done that. The code I originally posted reflects that.
>
>
>
> I know I’m not the only person having this problem. The folks at Mulesoft are having the same issue on the same server we’re using. This must be a bug unless somebody can show me the way…
>
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677145.html
> To start a new topic under ActiveMQ - Dev, email ml-node+s2283324n2368404h72@n4.nabble.com
> To unsubscribe from Multiple consumers not working with 1.6.2, click here.
> NAML
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677147.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
RE: Multiple consumers not working with 1.6.2
Posted by jaklug <ja...@hotmail.com>.
Artnaseef,
Messages are NOT being dispatched to each consumer. All the consumers
appear in the webconsole, but only the first consumer to connect actually
receives messages. I looked at the unit tests, but other than to get the
syntax of the prefetch value, they aren't very useful for this use case.
Hasn't anybody out there implemented a multiple consumer setup like this
before? Somebody must have an example of a client that, if I started two
instances of it, both would receive messages. I also looked at the link you
sent, and I had already tried/done that. The code I originally posted
reflects that.
I know I'm not the only person having this problem. The folks at Mulesoft
are having the same issue on the same server we're using. This must be a
bug unless somebody can show me the way.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677145.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: Multiple consumers not working with 1.6.2
Posted by artnaseef <ar...@artnaseef.com>.
Based on your description, it should work.
Check the consumers presence with the webconsole or JMX, and confirm
messages are being dispatched to each.
Another consideration is checking the syntax on the prefetch value; let me
try to find the correct way to set it.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-consumers-not-working-with-1-6-2-tp4677078p4677138.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.