From users-return-52309-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Thu Feb 27 18:55:02 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id B5ABE180181 for ; Thu, 27 Feb 2020 19:55:01 +0100 (CET) Received: (qmail 75378 invoked by uid 500); 27 Feb 2020 18:55:00 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Delivered-To: moderator for users@activemq.apache.org Received: (qmail 91221 invoked by uid 99); 27 Feb 2020 18:02:30 -0000 X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 5.53 X-Spam-Level: ***** X-Spam-Status: No, score=5.53 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, KAM_DMARC_NONE=0.25, KAM_DMARC_STATUS=0.01, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_SOFTFAIL=0.972, URIBL_BLOCKED=0.001, URI_HEX=0.1, URI_TRY_3LD=1.997] autolearn=disabled Received-SPF: Softfail (mailfrom) identity=mailfrom; client-ip=199.38.86.66; helo=n4.nabble.com; envelope-from=subbu.kobra@gmail.com; receiver= Date: Thu, 27 Feb 2020 12:02:35 -0600 (CST) From: "subbu.kobra" To: users@activemq.apache.org Message-ID: <1582826555262-0.post@n4.nabble.com> Subject: "queuePrefetch" policy doesn't seem to be working properly MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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