Skip to content

Queue Properties

Every time you declare a queue you pass a handful of flags. They look like boilerplate, but each one changes how long the queue lives and who can use it. Get them wrong and your queue either vanishes when you didn’t expect it to, or lingers forever when you wanted it gone.

There are three boolean flags and one bag of extra arguments.

A durable queue is written to disk, so its definition survives a RabbitMQ restart. A non-durable (transient) queue is forgotten when the broker restarts.

This is the flag people most often get wrong, so be precise: durable preserves the queue itself, not the messages in it. To keep the messages too, they must also be published as persistent (next lesson). Durable queue + persistent messages is the combination for “survives a restart” — one without the other still loses data.

For any queue that matters, set durable: true.

exclusive — one connection only, then gone

Section titled “exclusive — one connection only, then gone”

An exclusive queue can only be used by the connection that declared it, and it is deleted automatically when that connection closes. It’s perfect for a temporary, private reply queue (you’ll see this in the RPC lesson), and wrong for anything shared.

auto-delete — gone when the last consumer leaves

Section titled “auto-delete — gone when the last consumer leaves”

An auto-delete queue is deleted once its last consumer unsubscribes (it must have had at least one). Useful for transient subscriptions where the queue has no reason to exist after the subscriber goes away.

// durable: true → the queue definition survives a broker restart
await channel.assertQueue('orders', {
durable: true,
exclusive: false,
autoDelete: false,
});

Beyond the three booleans, queues take an arguments table (often called x-arguments because the keys start with x-). These unlock the more advanced behaviour covered later in this course:

ArgumentWhat it does
x-message-ttlMessages expire after N milliseconds
x-expiresThe queue itself is deleted after being unused for N ms
x-max-lengthCap the number of messages; overflow is dropped or rejected
x-dead-letter-exchangeWhere expired/rejected messages go (the DLX lesson)
x-queue-typeclassic or quorum (the clustering lesson)
What exactly does a durable queue preserve across a broker restart?
When is an exclusive queue deleted?
An auto-delete queue is removed when:
Where do you configure things like message TTL, max length, and dead-lettering?