Integration / RabbitMQ Interview Questions
What happens when a queue has no consumers?
If a queue has no active consumers, messages simply keep accumulating in it - they are not lost, as long as the queue itself still exists.
What happens next depends on the queue's configuration:
- A normal durable queue just grows, consuming more memory and disk over time.
- An
auto-deletequeue is only removed once it has had at least one consumer that later disconnects - a queue that never had a consumer is not auto-deleted. - If
x-max-lengthor a similar limit is set, older messages start getting dropped or dead-lettered once the limit is reached. - If
x-message-ttlis set, individual messages expire and are removed or dead-lettered after their TTL passes.
Unbounded growth with no consumers is a common cause of the memory/disk alarms that trigger RabbitMQ's flow control.
More Related questions...