Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ: How to prevent QueueDeclare to automatically generate a new Queue

With RabbitMQ I am doing something similar to this:

channel.QueueDeclare(QueueName, true, false, false, null);

By default RabbitMQ creates a new queue if none of the existing matches the name provided. I would like to have an exception thrown instead. Is that possible?

Thanks

like image 716
ab_732 Avatar asked Feb 12 '15 00:02

ab_732


People also ask

How to delete a queue in RabbitMQ?

Step 1: Navigate to the RabbitMQ management portal, type your credentials and log in. Step 2: Go to the Queues tab, and click on the name of the Queue you want to delete. Step 3: After you’ve chosen the queue you want to delete, you’ll be taken to its detail page where you’ll find a delete or purge option towards the bottom of the list.

What are enqueues in RabbitMQ?

Queues in RabbitMQ are ordered collections of messages. Messages are enqueued and dequeued (consumed) in the FIFO manner, although priority queues, sharded queues and other features may affect this.

How does The RabbitMQ exchange work?

In RabbitMQ, a producer never sends a message directly to a queue. Instead, it uses an exchange as a routing mediator. Therefore, the exchange decides if the message goes to one queue, to multiple queues, or is simply discarded.

What happens when RabbitMQ quits or crashes?

When RabbitMQ quits or crashes it will forget the queues and messages unless you tell it not to. Two things are required to make sure that messages aren't lost: we need to mark both the queue and messages as durable. First, we need to make sure that the queue will survive a RabbitMQ node restart.


1 Answers

Passive declarations are made for this. Use IModel.QueueDeclarePassive():

model.QueueDeclarePassive("queue-name");

This does nothing if the queue already exists, and raises an exception otherwise.

like image 98
Cyrille Claustre Avatar answered Nov 08 '22 12:11

Cyrille Claustre