2

I am attempting to use ActiveMQ 5.8.0 message groups in my application, and am not getting the results that I expected after reading the documentation.

I start two (or more) consumers for a particular queue, and then I send messages to the queue. In the producer's createMessage method, I am using:

message.setStringProperty("JMSXGroupID", "foo");

to set the GroupID. Note that for testing purposes, I am hard-coding "foo". It will eventually be a string set by the producer.

Since I only have a single message group being set in my messages, I expected to see that one consumer would become active and consume all of the messages in the queue, while the other one would remain quiescent.

Instead, I see the first message get processed by the first consumer, and then the second message get processed by the second consumer after the first consumer is finished. The consumers continue to take turns in this manner until all of the messages are consumed.

Is this the expected behavior, or is there some additional configuration that I need to do on either ActiveMQ or my producer or consumer to make sure that each GroupID gets associated to a single consumer.

David Raitt
  • 21
  • 1
  • 4

1 Answers1

2

AMQ message groups just guarantees that a single consumer will be active for a given group ("foo", etc) at a time...it doesn't bind that group to a specific consumer, so AMQ's internal consumer load balancing is likely just alternating between consumers.

regardless, this shouldn't be an issue when you are using dynamic JMSXGroupID values with multiple consumers, etc.

Ben ODay
  • 20,784
  • 9
  • 45
  • 68
  • 3
    I know your answer is quite old, still, could you elaborate why you think that it not tied to a given consumer? I interprete http://activemq.apache.org/message-groups.html as quite the contrary, as it states that the consumer "will receive all further messages with the same JMSXGroupID value until:" "someone closes the message group by sending a message with a negative value for JMSXGroupSeq". – Martin C. Jul 20 '15 at 09:26
  • 3
    ... And I forgot the second condition, "the consumer closes", but still, for me this is quite clear that messages within a group do not bounce between consumers, as long as the owning consumer still exists. – Martin C. Jul 20 '15 at 10:19