Updated on 2025-09-03 GMT+08:00

Configuring a RabbitMQ Exclusive Queue

An exclusive queue is visible and accessible only to the connection that declares it for the first time. The connection can be used to produce and consume messages, and clear and delete the queue. Other connections can neither access the queue, nor declare another exclusive queue with its name.

An exclusive queue cannot be persistent. Once the connection is closed, the queue and its data are automatically deleted.

Generally, exclusive queues temporarily store messages and the connection is shared by a producer and a consumer.

Notes and Constraints

  • Even if an exclusive queue is declared persistent, it is deleted upon the disconnection.
  • Exercise caution and note that queue data may be lost.

Example Configuration

On a Java client:

boolean durable = false;  //Whether to enable persistence.
boolean exclusive = true;  //Whether to enable exclusion.
boolean autoDelete = true;  //Whether to enable automatic queue deletion.
Map<String, Object> arguments = new HashMap<>();  //Other parameters
channel.queueDeclare(EXCLUSIVE_QUEUE_NAME, durable, exclusive, autoDelete, arguments);