You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Juri Robl (JIRA)" <ji...@apache.org> on 2017/04/21 16:18:04 UTC

[jira] [Created] (AMQNET-564) Individual Acknowledgements are slow for large amounts of messages

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)