49 RabbitMQ interview questions with detailed answers, sorted from basic to advanced. Free to practice, with progress saved automatically.
RabbitMQ is a message broker that lets services communicate asynchronously through queues instead of calling each other directly. Questions cover exchange types and routing, the work queue pattern, reliability and performance, dead-letter exchanges, poison messages, delayed delivery, clustering for high availability, and monitoring and operations.
RabbitMQ is an open-source message broker that enables applications to communicate asynchronously by sending messages through a central broker rather than calling each other directly. The basic flow has four roles: - Producer: the application that sends a message. - Exchange: receives the message and…
AMQP (Advanced Message Queuing Protocol) is a binary protocol that defines how a client talks to a message broker: open a connection, send messages, receive messages, confirm they were processed. Because the protocol is standardized, a Python app can send a message that a Java…
With a direct API call (REST, gRPC), service A sends a request straight to service B and waits for the response. Both must be running at that moment, and A must know B's address. This is tight coupling: if B is down or slow, A…
RabbitMQ core components: Producers (send messages), Exchanges (route messages), Queues (store messages), Consumers (receive and process), and Bindings (routing rules connecting exchanges to queues). Think of it as a post office: the producer is the sender dropping letters (messages) at the post office, the sorting…
A queue is a buffer storing messages from producers, waiting for consumers to retrieve and process them. Three points to know: - Order: messages are delivered FIFO, though priority queues are supported. - Multiple consumers: a queue can have multiple consumers, and RabbitMQ distributes messages…
A producer is an application that creates and sends messages, usually triggered by an event (a user signs up, an order is placed). A consumer is an application that receives messages from a queue and processes them. A producer does not send straight into a…
A binding is a rule connecting an exchange to a queue, specifying which messages get routed there. With direct and topic exchanges, bindings use a routingkey string as matching criteria — for example, binding a "orders" queue to a "direct" exchange with routingkey "neworder" means…
A routingkey is a label string attached to a message when the producer publishes it (for example user.created.vn). The exchange compares it with each queue's binding key to decide which queues receive the message. How matching works depends on the exchange type: - direct: the…
An exchange receives messages from producers and decides which queues to move them into, based on bindings and the routing key. The exchange itself does not store messages. The exchange type decides how matching works: - direct: the message's routing key must exactly equal the…
A connection is one TCP connection between the application and the broker. Opening one costs a TCP handshake, authentication and the AMQP negotiation steps (plus a TLS handshake if TLS is on), so connections are meant to be long-lived rather than opened per operation. A…
Message persistence means RabbitMQ writes the message to disk so it survives a broker restart or crash. A transient message (non-persistent, the default in most clients) lives only in RAM and is dropped when the broker restarts. Setting the persistent flag alone is not enough.…
Acknowledgment (ack) is the signal a consumer sends to RabbitMQ to say "this message is fully processed, you can remove it from the queue". There are two modes: - Manual ack (the default): the consumer calls ack itself after processing. If the consumer crashes or…
A virtual host (vhost) is a logically separate area inside one RabbitMQ broker. Exchanges, queues, bindings and policies belong to a specific vhost, so two queues both named orders in two vhosts are different queues. A client picks a vhost when it connects and can…
Messages still arrive and accumulate in the queue; they are not lost. This is by design: a queue exists to hold messages while consumers are temporarily down (deploying, crashed), and when a consumer comes back it works through the backlog. Messages disappear only when their…
A message consists of a payload (actual data — JSON, binary, text) and metadata (headers, properties like delivery mode, correlation ID, timestamp). RabbitMQ treats the payload as an opaque byte array — it never inspects or modifies content, leaving serialization to the application. Messages can…
Use a message queue when: - The task runs in the background and the user does not wait for the result: sending email, processing images, writing analytics logs. - You need to absorb a sudden traffic spike: producers push into the queue and consumers work…
Four exchange types: 1. Direct: exact routing key match, for task distribution to specific workers. 2. Fanout: broadcasts to all bound queues regardless of routing key, for notifications. 3. Topic: wildcard pattern matching ( matches exactly one word, matches zero or more words, words separated…
A direct exchange delivers a message to the queues whose binding key exactly matches, character for character, the message's routing key. There are no wildcards and no partial matching. A message with routing key user.created reaches both email-worker and audit-log, each getting its own copy.…
A fanout exchange ignores the routing key and delivers a copy of every message to all queues bound to it. Use it when several independent systems all need the same event (the publish/subscribe model). The three queues email, sms and audit are all bound to…
A topic exchange routes messages by pattern on the routing key. The routing key is words separated by dots (orders.payment.failed). Binding keys use two wildcards: matches exactly one word, matches zero or more words. The message orders.payment.failed matches both patterns, so it goes into both…
A headers exchange ignores routing keys and routes based on message header attributes. When binding, you specify matching rules like "department: sales" and "urgent: true" — messages only get routed if their headers match. When a binding lists several headers, the x-match argument on the…
Yes, absolutely. Multiple queues can bind to the same exchange, and each queue gets its own copy of a message if its binding matches. A queue whose binding does not match the routing key receives nothing. So for one message to reach several queues, each…
The message is silently dropped. An exchange only routes, it does not store messages; with no bindings there is no queue to receive it, so the broker drops it and by default tells the publisher nothing. This is usually a configuration bug: a wrong routing…
Use clear hierarchical naming: - Exchanges: indicate type or domain (e.g., "events", "tasks", "notifications"). - Routing keys: reflect the resource hierarchy as <resource.<event (e.g., "user.created", "order.payment.failed", "inventory.stock-low"). This structure lets topic exchanges bind by pattern, such as order. to receive every order event. - Format:…
An exchange is where producers send messages, and it stores nothing: it only decides which queues a message goes into. A queue is where messages actually wait until a consumer takes them and acknowledges them. Producers do not write straight into a queue, and consumers…
A dead-letter exchange (DLX) is a normal exchange that a source queue designates to receive discarded messages instead of deleting them. A message is dead-lettered when: 1. A consumer calls basic.reject or basic.nack with requeue=false. 2. The message's TTL expires. 3. The queue exceeds its…
Prefetch count (set with basic.qos) is the maximum number of messages delivered to a consumer that are not yet acked. Once it hits that limit, the broker stops delivering to that consumer until it acks some. Prefetch only applies with manual acks; 0 means unlimited.…
TTL (Time To Live) specifies how long a message can exist in a queue before expiring and being discarded or sent to the dead-letter exchange. Use it when messages lose their value after some time — e.g., a job that sends an SMS OTP code…
Priority queues let you assign priority levels to messages so higher-priority messages are consumed first. For classic queues, declare the queue with x-max-priority (keep ≤ 10 for performance). Message priority ranges from 0 to x-max-priority: a message with a higher priority than the maximum is…
Retries in RabbitMQ are driven by consumer acks. When processing fails, the consumer can nack with requeue (retry immediately) or nack without requeue to push the message to a dead-letter exchange (DLX). A common pattern is delayed retry through a wait queue with a TTL:…
Persistent messages (delivery mode 2) are written to disk and survive broker crashes and restarts — safe but slower due to disk I/O. Transient messages (delivery mode 1) are lost on broker restart (even if they were paged to disk under memory pressure, because the…
Publisher confirms are the producer-side equivalent of consumer acks: once confirm mode is enabled on a channel, RabbitMQ sends basic.ack to the producer after the message has been accepted by every queue it routed to (for a persistent message in a durable queue, after it…
Backpressure is how the broker forces senders to slow down when receivers can't keep up. RabbitMQ has three layers: - Credit-based flow control: always on, no configuration. Connections, channels and queues only accept more messages while they hold "credit" from the next stage. If a…
Separate them when an application both publishes and consumes heavily. The reason is how RabbitMQ throttles publishers: when memory or disk crosses its limit (a resource alarm), the broker blocks the whole TCP connection that is publishing, by stopping reading from that socket. It can't…
Work queue pattern distributes long-running tasks among multiple workers: the producer sends tasks to a single queue, several consumers listen on that queue, and each message is delivered to only one worker. Use it for image resizing, email sending, report generation, PDF export. The mechanism…
Pub/sub delivers the same message to multiple independent consumers. - Mechanism: the producer publishes to a fanout or topic exchange, multiple queues bind to it, and each queue gets its own copy and delivers it to its own consumer(s). - Unlike work queues: a work…
RPC over RabbitMQ is request/response through the broker: the client sends a request to a queue, the server processes it and sends the result to an address the client specified. Two message properties do the matching: - replyto: where the client wants the result. -…
Three options, pick by how much complexity you accept. 1. TTL + dead-letter exchange (no plugin). Push the message into a "waiting" queue with no consumer, set x-message-ttl = 30 minutes, and point x-dead-letter-exchange at the real processing exchange. When the TTL expires the message…
A poison message is a message that always makes the consumer fail. Since the consumer never acks, the broker redelivers, the consumer fails again — an infinite loop that consumes the whole consumer budget and starves valid messages behind it. Common causes: payload that does…