activemq-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juri Robl (JIRA)" <>
Subject [jira] [Created] (AMQNET-564) Individual Acknowledgements are slow for large amounts of messages
Date Fri, 21 Apr 2017 16:18:04 GMT
Juri Robl created AMQNET-564:

             Summary: Individual Acknowledgements are slow for large amounts of messages
                 Key: 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:

foreach (MessageDispatch originalDispatch in this.deliveredMessages)
 if (originalDispatch.Message.MessageId.Equals(message.MessageId))
    dispatch = originalDispatch;

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.

// 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

This message was sent by Atlassian JIRA

View raw message