Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 418A0200C4E for ; Fri, 21 Apr 2017 18:26:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 40564160BA2; Fri, 21 Apr 2017 16:26:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 79CDA160BB2 for ; Fri, 21 Apr 2017 18:26:35 +0200 (CEST) Received: (qmail 20015 invoked by uid 500); 21 Apr 2017 16:24:20 -0000 Mailing-List: contact issues-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list issues@activemq.apache.org Received: (qmail 19217 invoked by uid 99); 21 Apr 2017 16:18:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Apr 2017 16:18:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 236A8C00A3 for ; Fri, 21 Apr 2017 16:18:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.002 X-Spam-Level: X-Spam-Status: No, score=-0.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id j9_0X7U0BN_a for ; Fri, 21 Apr 2017 16:18:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id A81B35F485 for ; Fri, 21 Apr 2017 16:18:05 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id C790DE0D6C for ; Fri, 21 Apr 2017 16:18:04 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 1DBD121B57 for ; Fri, 21 Apr 2017 16:18:04 +0000 (UTC) Date: Fri, 21 Apr 2017 16:18:04 +0000 (UTC) From: "Juri Robl (JIRA)" To: issues@activemq.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (AMQNET-564) Individual Acknowledgements are slow for large amounts of messages MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 21 Apr 2017 16:26:36 -0000 Juri Robl created AMQNET-564: -------------------------------- Summary: Individual Acknowledgements are slow for large amounts of messages Key: AMQNET-564 URL: https://issues.apache.org/jira/browse/AMQNET-564 Project: ActiveMQ .Net Issue Type: Bug Components: ActiveMQ Affects Versions: 1.7.2 Environment: .NET 4.5.2 Apache.NMS 1.7.1 Apache.NMS.ActiveMQ 1.7.2 Reporter: Juri Robl Priority: Minor When using the asynchronious Listener, the consumer gets pushed as many messages as possible from the queue. Using Individual Acknowledgement-Mode all messages need to be Acked. When the consumer loads many messages (>>25.000) the Ack. performance degrades badly (< 20 messages / s). New messages the consumer recieves are stored at the front of a LinkedList. Before the ack is send, the Consumer searches the list front-to-end. Because I (and most people probably) want to ack one of the oldest messages, the whole list needs to be traversed. Afterwards the found message is removed from the list, which traverses the list once again. The Code in question from MessageConsumer.cs: {code} foreach (MessageDispatch originalDispatch in this.deliveredMessages) { if (originalDispatch.Message.MessageId.Equals(message.MessageId)) { dispatch = originalDispatch; this.deliveredMessages.Remove(originalDispatch); break; } } {code} I tried two changes to the code, and it is orders of magnitude faster for large amounts of messages (if the oldest message always needs to be acked). I used reflection to access the needed methods/fields because I had some problems compiling the original code. {code} // Reverse the iteration for (var deliveredMessageNode = deliveredMessages.Last; deliveredMessageNode != null; deliveredMessageNode = deliveredMessageNode.Previous) { var deliveredMessage = deliveredMessageNode.Value; if (deliveredMessage.Message.MessageId.Equals(message.MessageId)) { dispatch = deliveredMessage; // Use the node to remove the message, don't search again for it deliveredMessages.Remove(deliveredMessageNode); break; } } {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)