Search code examples
javarabbitmqamqp

rabbitmq (AMQP): delete all messages from a queue


There are some questions like mine on SO, but purge method is not suitable for me. From AMQP docs:

Purge a queue. This method removes all messages from a queue which are not awaiting acknowledgment.

What if I want to delete really all messages even if they are waiting acks? Is there any solution?

Thanks in advance!


Solution

  • AFAIK, you can't delete unacked messages. What you can do is get them back in ready state with basic.recover() or by killing the connection responsible for the unacked messages. After that you can purge the queue.