How to remove specific message from queue in rabbitmq
Asked Answered
F

2

9

I use rabbitmq. I created a queue and put 10 messages here.

I want to delete only specific one of 10 messages here. Is there a way to delete it?

Fortney answered 13/11, 2018 at 3:42 Comment(1)
That does not sound very „message queue like“. If you want to delete just one of the messages, you have to fetch all with a suitable RabbitListener within your spring application. And after you identified your specific message, you need to gracefully reject all the other messages. But if you do that, you will find yourself in a infinity loop. I guess you have to use some tools of rabbitmq to forward your messages into „queue A“ (valid messages) and „queue B“ (invalid messages)Bryon
S
6

No, there is no way to do that directly. Some alternatives are:

  1. Purge the queue and add back the 9 other messages
  2. Check for that one message on the consumer side and reject/ignore that message
  3. Forward all the messages to another queue, except for that 1 message
Spinozism answered 13/11, 2018 at 4:1 Comment(0)
P
0

The rabbitmq API doesn't seem to support deleting a separate message, but only purging all of them: sudo rabbitmqctl purge_queue <queue name>

However, you can use tricks as written here How to delete a specific message from RabbitMQ Queue? and here is his package rabbitmq-delete-message if you are comfortable with node.js

Pericles answered 3/2, 2023 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.