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:
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.