This is expected behavior. When a message with a JMXGroupId is dispatched
to a consumer, that consumer is the sole one that will receive future
messages with the same JMXGroupId, until the connection from the consumer
to the broker is broken.

Here's your sequence of events, with additional commentary that illustrated
the impact of what I described above:

message 1 with JMXGroupId 1 - consumed by Thread 1, which locks JMXGroupId
1 to Thread 1.
message 2 with JMXGroupId 2 - consumed by Thread 2, which locks JMXGroupId
2 to Thread 2.
message 3 with JMXGroupId 3 - consumed by Thread 1, which locks JMXGroupId
3 to Thread 1.
message 4 with JMXGroupId 3 - JMXGroupId 3 is already locked to Thread 1,
so the broker waits until Thread 1 is available.
message 5 with JMXGroupId 1 - JMXGroupId 1 is already locked to Thread 1,
so the broker waits until Thread 1 is available.

If you want messages to be load balanced across your consumers (i.e.
competing consumers), they need to not be assigned to message groups.

Tim


On Thu, Feb 27, 2020 at 3:02 PM subbu.kobra <[email protected]> wrote:

> Thanks for the quick response.
>
> I am using ActiveMQ 5.15.10 and we are connecting to activemq using
> MuleSoft
> which is running on 3.9.0 runtime version. I have set the queue prefetch at
> the connection level (not at the broker) like below.
>
> tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1
>
> I could see in the activemq console that the prefetch value as 1.
>
> <http://activemq.2283324.n4.nabble.com/file/t379803/prefetch_image.jpg>
>
> If my understanding is correct, based on the prefetch value, activemq will
> prefetch that many number of messages to the consumer while consumer is
> handling a transaction already. in my case since I have set prefetch as 1,
> it should prefetch only one but I don't this is happening correctly.
>
> Note:  we are using "JMXGroupId" property in our project. When we set the
> JMXGroupId, activemq will make sure that if one consumer thread is handling
> a transaction with one JMXGroupId and if it receives another message with
> same JMXGroupId, it will deliver to the same consumer thread.
>
> As per my example in the post (or provided below once again)
>
> <http://activemq.2283324.n4.nabble.com/file/t379803/active_mq_timings.jpg>
>
>
>
> In the above picture, In the above picture, M3 is assigned to thread 1
> (hoping that M3 is prefetched to thread 1 as we are using queue prefetch as
> 1) but after M2 is finished at "2020-02-21 12:43:03,323" why M5 with
> JMXGroupId "1" is not assigned to Thread 2.
>
> Anyway there are no messages with JMXGroupId "1" in the queue or with any
> consumer thread.
>
> Due to which we are losing the processing time for Message 5.
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>

Reply via email to