0

I have done some research and not able to find any solution to delete or modify a message which is already present in a queue.(RabbitMQ).

Use case: I am trying to send notification by using delayed message feature (headers.put("x-delay", 5000)) in RabbitMQ(lets say after 30 mins). I want to send an event which can delete/modify the content of the message. Is there any way to do this in RabbitMQ.

Alternate approach is to use database and scheduler which i will implement if this is not possible.

Thanks in advance

Imran Ahmad
  • 206
  • 1
  • 13
  • I am not sure what "send notification delayed message". In rabbitmq you can send messages in a delayed fashion using https://www.rabbitmq.com/blog/2015/04/16/scheduling-messages-with-rabbitmq/ But to answer your original question to delete a message you probably would just need to consume it from the queue and re-post a modified message – Anand Sunderraman Jun 03 '20 at 09:40
  • @AnandSunderraman thanks for the reply, i am using scheduling message only. updated that line in question. Yeah that is an option but it will fail if the consumer is third party. I was wondering if there is any feature in RabbitMQ or i can achieve this by some customization. – Imran Ahmad Jun 03 '20 at 13:24

1 Answers1

0

Not really sure about your scenario. Assuming you want to delete or modify an existing message on RabbitMQ.

If you have a FIFO situation you can check this How to selectively delete messages from an AMQP (RabbitMQ) queue?

What I can suggest is, you can use insert and delete approach, push the modified message with unique id to db/cache and your message queue. And whenever you make a modification or deletion remove it from db/cache. And when consumer is consuming the message, it can ignore if it's not present in db/cache.