I noticed that invoking QueueControl#removeAllMessages
can return a value less than the number of messages in the queue seen by QueueControl#getMessageCount
. I observed it to be up to 32,768 messages less when I simulated an unresponsive consumer. I tracked this down to prefetch (consumerWindowSize
for Artemis clients) as the cause, which makes sense (and verified that setting prefetch to 0 caused us to result in a message count of 0 afterwards).
If I do removeAllMessages
and I have a client using prefetch, does this ensure all memory on the queue is free-able? Or are those messages that are still “being delivered” held onto by the Artemis broker and hence not able to be freed? If this is the case, is there a way to ensure the broker no longer retains reference to these delivering messages? I am implementing an automated queue purge for unresponsive queue consumers to free up memory, and want to ensure this stays effective with clients prefetching messages.