Hi, We are using ActiveMQ and MuleSoft in our project. We connect to ActiveMQ from MuleSoft.
As per the project requirement, we are using JMXGroupId and Queueprefetch polcy. We have set Queueprefetch to 1 at the connection broker url like below and number of consumers are set to 2 tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1 We have two APIs in mule one APIs publishes messages to the queue and another API consumes the messages from the queue. in the receiver API, we have set sleep time to 10secs (for POC to reproduce the issue) 2020-02-21 12:42:52,203 [[jms_connectivity_poc]org.mule.api.processor.LoggerMessageProcessor: Written to the queue : M1 (JMXGroupId : 1) 2020-02-21 12:42:52,244 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: received : M1 (JMXGroupId : 1) 2020-02-21 12:42:53,315 [[jms_connectivity_poc]org.mule.api.processor.LoggerMessageProcessor: Written to the queue : M2 (JMXGroupId : 2) 2020-02-21 12:42:53,322 [ActiveMQ Session Task-2] org.mule.api.processor.LoggerMessageProcessor: received : M2 (JMXGroupId : 2) 2020-02-21 12:42:57,077 [[jms_connectivity_poc]org.mule.api.processor.LoggerMessageProcessor: Written to the queue : M3 (JMXGroupId : 3) 2020-02-21 12:42:58,148 [[jms_connectivity_poc]org.mule.api.processor.LoggerMessageProcessor: Written to the queue : M4 (JMXGroupId : 3) 2020-02-21 12:43:01,736 [[jms_connectivity_poc]org.mule.api.processor.LoggerMessageProcessor: Written to the queue : M5 (JMXGroupId : 1) 2020-02-21 12:43:02,248 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: finished : M1 (JMXGroupId : 1) 2020-02-21 12:43:02,257 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: received : M3 (JMXGroupId : 3) 2020-02-21 12:43:03,323 [ActiveMQ Session Task-2] org.mule.api.processor.LoggerMessageProcessor: finished : M2 (JMXGroupId : 2) 2020-02-21 12:43:12,258 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: finished : M3 (JMXGroupId : 3) 2020-02-21 12:43:12,263 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: received : M4 (JMXGroupId : 3) 2020-02-21 12:43:22,264 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: finished : M4 (JMXGroupId : 3) 2020-02-21 12:43:22,269 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: received : M5 (JMXGroupId : 1) 2020-02-21 12:43:32,270 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: finished : M5 (JMXGroupId : 1) If you see the above log, We have written the messages to the queue in the following sequence: message 1 with JMXGroupId 1 message 2 with JMXGroupId 2 message 3 with JMXGroupId 3 message 4 with JMXGroupId 3 message 5 with JMXGroupId 1 Since there are two consumer threads, first two messages were picked up by consumer 1 and consumer 2 and If I understand prefetch functionality correctly, Message 3 is prefetched to consumer thread 1. Even though consumer thread 2 is available after some time (i.e. 2020-02-21 12:43:03,323), Last Message (i.e. M5) with JMXgroupId 1, was given to thread 1 (at 2020-02-21 12:43:22,269) due to which we are losing the processing time for Message 5. Can you please let me know why Message 5 with JMXgroupId 1 (i.e. Last message) waited for so long and assigned to Thread 1 when Thread 2 is available? do we need to do any changes in the ActiveMQ configuration or any other changes so that it will assign the Message 5 with JMXgGroup 1 to Thread 2? Thanks, Bala -- Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html