RabbitMQ Interview Questions
Follow a message from publish to committed business effect. At each step, explain what the broker knows and what the application still has to guarantee.
Try answering aloud before opening each explanation.
Try the RabbitMQ practice demoFoundations
What do exchanges, bindings and queues each do?
A publisher sends to an exchange. Bindings describe how it routes, and queues hold the routed messages for consumers. The same publish can reach more than one queue.
How do direct, fanout and topic exchanges select destinations?
Direct exchanges use an exact routing-key match, fanout exchanges ignore the key and route to bound queues, and topic exchanges match key segments against binding patterns.
How does a publisher confirm differ from a consumer acknowledgement?
A confirm describes the broker's responsibility for the publish under the queue's guarantees. A consumer acknowledgement tells the broker that a specific delivery can be removed. Neither proves both happened.
Does declaring a queue durable make every published message persistent?
No. Queue durability concerns the queue definition; message delivery mode governs message persistence where applicable. Use confirms to observe broker acceptance, not just successful client-side writes.
What does prefetch control?
It limits deliveries awaiting acknowledgement according to the configured scope. Set it with processing concurrency and memory in mind rather than using it as a delivery-rate limit.
Applied
What happens if a consumer loses its connection before acknowledging a delivery?
The broker can requeue the unacknowledged message. The business operation might already have committed, so design the consumer to tolerate processing the same event again.
When should a consumer acknowledge after writing to a database?
Acknowledge after the transaction commits. For duplicates, make the write idempotent or record the message ID in the same transaction so redelivery cannot repeat the effect.
Can the broker confirm an unroutable publish?
Yes. A confirm alone is not evidence that a queue matched. When using the mandatory flag, handle returned messages separately and correlate them with the publication.
Why can immediate requeue of every failure hurt throughput?
A failing message can be redelivered repeatedly without giving the dependency time to recover. Use capped retries with delay, then move exhausted work into a defined failure path.
What does a dead-letter exchange do?
It receives messages dead-lettered by a queue under configured conditions, such as a rejection without requeue. It still needs bindings to route messages to an intended destination.
Production scenarios
How do you distinguish a producer surge from blocked RabbitMQ consumers?
Compare publish, delivery and acknowledgement rates and the counts of ready and unacknowledged messages. Growing unacknowledged work can point to slow handlers; increasing ready work with stable processing can indicate excess arrivals.
Can you assume messages are processed in order with several consumers?
No. Delivery order and completion order differ, and redelivery can change effective order. If an entity requires ordered effects, coordinate its consumers and enforce sequencing in application state.
What does a quorum queue trade for resilience?
It replicates queue state across members using a consensus protocol. It depends on a majority being available and adds replication cost; place replicas across appropriate failure domains.
A publisher connection drops before a confirm arrives. What should the publisher assume?
The outcome is unknown: the broker may have accepted the message. Retrying preserves delivery chances but can produce duplicates. Keep a stable message identifier and make consumers replay-safe.
How do you drain a RabbitMQ consumer during rollout?
Stop accepting new deliveries, finish or safely abandon in-flight work, and acknowledge only successful commits. Let unresolved deliveries be requeued when the channel closes and verify handlers are safe on replay.
Further reading
Official documentation
Related question sets
- Node.js interview questions
- TypeScript interview questions
- REST API interview questions
- Microservices interview questions
- SQL interview questions
- Python interview questions
- JavaScript interview questions
- React interview questions
- Kubernetes interview questions
- System Design interview questions
- Java interview questions
- Docker interview questions
- MongoDB interview questions
- PostgreSQL interview questions
- Redis interview questions
- NestJS interview questions