Skip to content
Advertisement

Re-creating a queue afters its manually deleted RabbitMQ

Is it possible to automatically re-create a queue afters it has been manually removed?

I’m able to create the queue on start up using

JavaScript

However, if it’s manually removed from rabbitmq, I want to be able to create a queue with the same name automatically.

Today if I remove it, I will keep throwing exceptions like

JavaScript

Advertisement

Answer

Yes, you can re-create the queue which you have deleted. In RabbitMQ each operation is an event. When a queue is deleted, it is recorded as an event and these events can be consumed like normal messages.

You can enable RabbitMQ events by enabling the rabbitmq_event_exchange plugin. Once it is set, bind it to a queue. While consuming the messages from the events-queue, you need to check for the message that contains queue.deleted. If there is any such message, you can re-create the queue. The queue.deleted event will also contain the queue name and the virtual host

Reference: https://www.rabbitmq.com/event-exchange.html

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement