All Products
Search
Document Center

ApsaraMQ for RabbitMQ:Declaring exclusive queues

Last Updated:Jun 02, 2026

Exclusive queues in ApsaraMQ for RabbitMQ are visible only to the connection that created them and are automatically deleted when that connection closes.

What is an exclusive queue?

Exclusive queues have these characteristics:

  • An exclusive queue is visible only to the channels in the connection that first declared it.

    Other connections cannot declare an exclusive queue with the same name or access the exclusive queue.

  • An exclusive queue is automatically deleted when its connection closes.

    Even if you set durable to true, the queue and its data are deleted when the connection closes.

Common scenarios

Use exclusive queues when producers and consumers run in the same process and can tolerate data loss.

Risks

An exclusive queue and its data are deleted if the connection closes unexpectedly. Common causes:

  • The client calls the Close() method

  • Broker updates or unexpected restarts

  • Connection heartbeat timeout

  • Other errors such as throttling

Use exclusive queues with caution.

How to declare an exclusive queue

Call channel.queueDeclare with the exclusive parameter set to true.

Java example:

/**
* queue: the queue name. 
* durable: specifies whether to persist the queue. 
* exclusive: specifies whether the queue is exclusive. 
* autoDelete: specifies whether to automatically delete the queue. 
* arguments: other parameters. 
*/
channel.queueDeclare("queueName", true, true, false, null);