Integration / RabbitMQ Interview Questions
1. What is RabbitMQ?
RabbitMQ is an open-source message broker that accepts messages from producer applications and routes them to consumer applications, letting the two sides run independently of each other. It is written in Erlang, which gives it strong support for concurrency and fault tolerance, and it natively s...
2. What is a message broker?
A message broker is middleware that sits between applications and manages the exchange of messages between them, so the sender and receiver never talk to each other directly. It typically takes care of routing, temporary storage, delivery guarantees, and protocol translation, which removes the ne...
3. What is AMQP?
AMQP (Advanced Message Queuing Protocol) is an open, wire-level protocol that defines how messages are formatted, routed, and delivered between applications and a broker. Because it is a binary wire protocol rather than a vendor API, any AMQP-compliant client can talk to any AMQP-compliant broker...
4. What is a queue in RabbitMQ?
A queue is the buffer inside RabbitMQ where messages actually live once they have been routed there, waiting to be delivered to a consumer. Every queue is declared with a name and a set of properties that control its behavior: durable - survives a broker restart if true exclusive - usable only by...
5. What is an exchange in RabbitMQ?
An exchange is the component that receives messages from producers and decides which queue or queues should get a copy, based on the message's routing key, headers, and the bindings configured on it. Every exchange has a type - direct, fanout, topic, or headers - which determines the routing algo...
6. What are the types of exchanges in RabbitMQ?
RabbitMQ ships with four built-in exchange types, each using a different rule to decide which queues receive a message. Exchange Type Routing Behavior Direct delivers to queues whose binding key matches the message's routing key exactly. Fanout ignores the routing key and broadcasts to every boun...
7. What is a binding in RabbitMQ?
A binding is the rule that connects an exchange to a queue (or to another exchange) and tells the exchange under what conditions it should forward a message there. For a direct or topic exchange, a binding carries a binding key that is compared against the message's routing key. For a headers exc...
8. What is a routing key?
A routing key is a string attribute attached to a message when it is published, which the exchange uses to decide where the message should go. Its meaning changes with the exchange type: Direct exchange - must match a binding key exactly. Topic exchange - matched against a dot-separated pattern s...
9. What is a producer in RabbitMQ?
A producer is any application that creates a message and publishes it to an exchange over an open channel. The producer chooses the exchange name, the routing key, and message properties such as content type, persistence mode, and optional headers, but it has no direct knowledge of which queue, i...
10. What is a consumer in RabbitMQ?
A consumer is an application that subscribes to a queue using basic.consume (or polls it with basic.get ) and receives messages as they become available. After processing a message, the consumer sends back an acknowledgment, negative acknowledgment, or rejection, which tells RabbitMQ whether to r...
11. What is the purpose of the RabbitMQ management plugin?
The management plugin adds a browser-based UI and a REST API for observing and administering a RabbitMQ node or cluster. Through it, an operator can inspect queues, exchanges, bindings, connections, and channels, manage users, vhosts, and permissions, and view real-time message rates and node hea...
12. What are the types of acknowledgments in RabbitMQ?
RabbitMQ uses two independent acknowledgment mechanisms, one on the publishing side and one on the consuming side. Publisher-side Consumer-side Publisher confirms - broker tells the producer a message was safely received. Consumer acks - consumer tells the broker a message was processed. Async, n...
13. Define virtual host in RabbitMQ?
A virtual host (vhost) is a logical, isolated namespace inside a single RabbitMQ broker or cluster. Each vhost has its own exchanges, queues, bindings, and permissions, so two applications on the same broker can use identical names (like orders or logs ) without colliding. Vhosts are commonly use...
14. Describe how RabbitMQ ensures message durability?
Message durability in RabbitMQ depends on three things working together, and missing any one of them breaks the guarantee. The queue must be declared durable so its definition survives a broker restart. The message must be published with delivery_mode = 2 (persistent), so its body is written to d...
15. List the client libraries available for RabbitMQ?
Because RabbitMQ speaks standard AMQP 0-9-1, there are mature client libraries in essentially every mainstream language. Language Common Library Python Pika, aio-pika Java official RabbitMQ Java client, Spring AMQP Node.js amqplib .NET / C# RabbitMQ .NET client Ruby Bunny Go amqp091-go (maintaine...
16. How does RabbitMQ differ from Kafka?
RabbitMQ and Kafka solve overlapping problems but with fundamentally different internal models, which shows up clearly once you compare them side by side. RabbitMQ Kafka Smart broker: exchange evaluates routing rules and pushes to queues. Dumb broker, smart consumer: append-only log per partition...
17. Why do we use dead-letter exchanges in RabbitMQ?
A dead-letter exchange (DLX) is where RabbitMQ reroutes messages that could not be processed normally, instead of silently discarding them. A message becomes "dead-lettered" when any of the following happen: it is rejected or nacked with requeue=false , its TTL expires before it is consumed, the ...
18. How does RabbitMQ handle message acknowledgment?
RabbitMQ tracks every message it delivers to a consumer until that consumer confirms what happened to it, unless auto-ack was requested. basic.ack - the consumer processed the message successfully; it is removed from the queue. basic.nack / basic.reject - processing failed; the message can be req...
19. What is the difference between direct and topic exchange?
Both direct and topic exchanges route using the message's routing key, but they differ in how strict that matching is. Direct Exchange Topic Exchange Requires an exact string match between routing key and binding key. Matches routing key against a dot-separated pattern using * and #. Good for sim...
20. 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-delete queue is o...
21. How is message persistence achieved in RabbitMQ?
Persistence in RabbitMQ is opt-in and requires configuration on both the queue and the message, not just one of them. Declare the queue as durable so RabbitMQ remembers it exists after a restart. Publish the message with the persistent delivery mode ( delivery_mode=2 ), so the broker writes its b...
22. Why should you use prefetch count in RabbitMQ?
Prefetch count (set via basic.qos ) limits how many unacknowledged messages RabbitMQ will push to a consumer at once, instead of flooding it with the entire queue. Without a limit, a fast producer can hand a slow consumer thousands of messages it hasn't even started processing yet, which: wastes ...
23. When should you use a fanout exchange?
A fanout exchange broadcasts every message to all queues bound to it, completely ignoring the routing key, which makes it the natural choice whenever every subscriber needs the same copy of an event. Good fits include: Broadcasting a cache-invalidation event to every service instance. Fanning out...
24. What is the difference between durable and transient queues?
Durability is a property of the queue's metadata , not of the messages inside it, which is a common source of confusion. Durable Queue Transient Queue Definition survives a broker restart. Definition is lost when the broker restarts. Declared with durable=true. Declared with durable=false (the de...
25. How do you implement RPC pattern with RabbitMQ?
RabbitMQ can emulate request/response (RPC) even though it is fundamentally an asynchronous system, using two message properties: reply_to and correlation_id . The client declares a private, typically exclusive, reply queue and starts consuming from it. The client publishes the request, setting r...
26. Why does RabbitMQ use a heartbeat mechanism?
The AMQP heartbeat is a small periodic frame exchanged between client and broker purely to prove the TCP connection is still alive. Without it, a network failure (a dropped Wi-Fi connection, a silently closed firewall session, a crashed process that never sent a TCP FIN) could leave both sides be...
27. What is the difference between RabbitMQ and ActiveMQ?
RabbitMQ and ActiveMQ are both traditional message brokers, but they come from different ecosystems and make different core trade-offs. RabbitMQ ActiveMQ Written in Erlang; runs on the BEAM VM known for concurrency and fault tolerance. Written in Java; runs on the JVM. Native protocol AMQP 0-9-1,...
28. How can you optimize RabbitMQ throughput?
Throughput tuning in RabbitMQ is mostly about removing bottlenecks on the client side and avoiding broker configurations that force extra work per message. Batch acknowledgments - ack in small batches (multiple=true) instead of one at a time to cut protocol overhead. Tune prefetch - too low starv...
29. When would you choose quorum queues over classic queues?
Quorum queues replicate their data across multiple nodes using the Raft consensus algorithm, trading a bit of overhead for much stronger data-safety guarantees than classic queues. Choose quorum queues when: message loss on node failure is unacceptable (financial transactions, order events, audit...
30. What is the difference between publisher confirms and transactions?
Both mechanisms let a producer verify that RabbitMQ actually received a message, but they differ enormously in cost and design. Publisher Confirms Transactions (tx.select) Asynchronous - broker sends ack/nack per delivery tag without blocking the publisher. Synchronous - publisher calls tx.commit...
31. Explain the lifecycle of a message in RabbitMQ?
A message passes through several distinct stages between the moment a producer creates it and the moment it is finally removed from the broker. flowchart LR A[Producer creates message] --> B[Publish to Exchange with routing key] B --> C{Bindings match?} C -->|Yes| D["Message copied into matching ...
32. Explain the internal working of RabbitMQ clustering?
A RabbitMQ cluster is a group of nodes that share certain broker state over Erlang's built-in distribution protocol, but it does not automatically replicate every queue's contents. Shared across the cluster: exchanges, bindings, users, permissions, and vhost metadata are synchronized to every nod...
33. Why doesn't RabbitMQ guarantee message ordering in all cases?
RabbitMQ preserves strict FIFO order only within a single queue, delivered to a single consumer, and even then only under specific conditions - several common setups break that guarantee. Multiple consumers on one queue - messages are dispatched round-robin, so consumer A and consumer B may finis...
34. How does RabbitMQ handle high availability?
RabbitMQ offers high availability primarily through queue replication, with two generations of the feature that behave quite differently. Classic Mirrored Queues (legacy) Quorum Queues (recommended) Configured via a mirroring policy; one master, N mirrors. Configured natively at declare time; rep...
35. Explain the execution flow of a publisher confirm?
Publisher confirms let a producer track, asynchronously, whether each message it published was actually accepted by the broker. sequenceDiagram participant P as Producer participant B as Broker P->>B: channel.confirm_select() P->>B: basic.publish (delivery tag 1) P->>B: basic.publish (delivery ta...
36. How do you troubleshoot memory alarms in RabbitMQ?
A memory alarm fires when a node's memory use crosses vm_memory_high_watermark , and RabbitMQ responds by blocking publishers on the affected node until memory drops - a state visible in the management UI as flow control. Confirm the alarm with rabbitmqctl status or the management UI's node page,...
37. What is the difference between mirrored queues and quorum queues?
Both aim to keep a queue available if a node fails, but they use different replication designs with very different guarantees. Mirrored Queues (classic HA) Quorum Queues Uses a policy-driven master/mirror model. Uses a Raft-based leader/follower model, configured per queue. Mirrors can fall behin...
38. How does RabbitMQ implement the Raft consensus algorithm in quorum queues?
Each quorum queue is backed by its own independent Raft group - a set of replicas spread across cluster nodes that together maintain a single, ordered, replicated log of operations for that queue. One replica in the group is elected leader ; all client operations (publishes, consumes, acks) for t...
39. Why is TTL important for queues and messages in RabbitMQ?
Time-to-live (TTL) settings prevent stale data and idle resources from accumulating forever, at both the message level and the queue level. Message TTL ( x-message-ttl , or a per-message expiration property) removes a message once it has waited too long to be useful - a good fit for time-sensitiv...
40. How do you scale RabbitMQ horizontally?
Scaling RabbitMQ horizontally is less about "adding more nodes" alone and more about spreading load across queues, nodes, and even clusters in a deliberate way. Shard busy topics across multiple queues using a consistent-hash exchange, so a single hot queue doesn't become the bottleneck. Add clus...
41. Explain the internal working of the RabbitMQ shovel plugin?
The shovel plugin runs a small, resilient client inside (or alongside) RabbitMQ that behaves like a well-behaved consumer on one broker and a well-behaved producer on another, continuously moving messages between them. It opens its own AMQP connection to a source broker/queue and consumes message...
42. What is the difference between federation and shovel in RabbitMQ?
Federation and shovel both move messages between separate RabbitMQ brokers, but they target different problems. Federation Shovel Links exchanges (or queues) across brokers while preserving routing topology. Moves messages point-to-point from a source queue/exchange to a destination, without pres...
43. How does RabbitMQ handle network partitions in a cluster?
A network partition splits a cluster into two or more groups of nodes that can no longer see each other, and RabbitMQ's behavior in that scenario depends on the configured cluster_partition_handling strategy. Strategy Behavior ignore (default) Both sides keep running independently - risks a split...
44. Explain the lifecycle of a consumer connection and channel?
A consumer's path from nothing to actively receiving messages involves several distinct AMQP handshakes layered on top of each other. sequenceDiagram participant C as Consumer App participant B as Broker C->>B: TCP connect C->>B: connection.open (negotiate heartbeat, frame_max) B-->>C: connection...
45. How do you troubleshoot unacknowledged message buildup in RabbitMQ?
A growing "unacked" count on a queue means messages have been delivered to consumers but never confirmed, which ties up memory and, at high prefetch, can eventually trigger flow control. Check consumer health first - is the process alive, is it stuck in a long-running operation, or did it crash w...