RabbitMQ interview questions: exchanges, queues, acks and clustering
Reviewed by Mark Dickie · Last updated
5 questions on this page you can answer and see marked on the spot. Go to the first one
RabbitMQ is an open-source message broker that routes messages from producers to consumers using the AMQP 0-9-1 protocol, plus MQTT, STOMP and AMQP 1.0 through plugins. Interviewers expect you to explain how an exchange routes a message into queues through bindings, how acknowledgements and prefetch control delivery, and what happens when a consumer or node dies. Know when to pick quorum queues over classic ones, and be ready to compare RabbitMQ with Kafka.
What does a RabbitMQ interview test?
Questions usually start with the routing model and move to reliability and operations. This table maps the common exchange types to what they do.
| Exchange type | Routing rule | Typical use |
|---|---|---|
| direct | Exact match on routing key | Sending a task to one named queue |
| fanout | Ignores the key, copies to every bound queue | Broadcasting events to several services |
| topic | Pattern match with * (one word) and # (zero or more) | Log routing such as orders.*.failed |
| headers | Matches on message header attributes | Routing on metadata instead of a key |
How do you practise RabbitMQ for an interview?
Run a local broker with the management plugin and work through these exercises:
- Publish to a direct exchange with no matching binding and see the message dropped, then retry with the
mandatoryflag and a return handler. - Consume with manual acks, kill the consumer before acking, and watch the message return to the queue as redelivered.
- Set
basic.qosprefetch to 1 and compare how two uneven workers share the load. - Configure a dead-letter exchange with a per-queue TTL and
x-max-length, then trace where rejected and expired messages go. - Create a quorum queue on a three-node cluster, stop the leader, and observe the Raft election.
- Turn on publisher confirms and explain why durable queues and persistent messages are both needed to survive a restart.
Key facts
- Tarmac has 98 RabbitMQ interview questions on this topic, 10 of them on this page, at difficulty 1–5 of 5.
- Tarmac tracked 57 job postings asking for RabbitMQ in November 2026.
- Roles asking for RabbitMQ advertise a median base salary of £67,500, across 6 job postings as of November 2026.
- Tarmac last reviewed these RabbitMQ interview questions on 5 December 2026.
At a glance
| Questions | 10 shown · 98 in the bank |
|---|---|
| Difficulty | 1–5 of 5 |
| Formats | True / false, Ordering, Find the bug, Multiple choice, Short answer, Fill in the blank, Multiple answer, Code output, Flashcard |
What you'll review
- rmq producers consumers
- rmq virtual hosts
- rmq cluster basics
- rmq connections channels
Practice questions
Try one before you open the answer. Pick an option and press Check; it's marked on the spot.
In RabbitMQ's AMQP 0-9-1 model, producers publish messages to an exchange, not directly into a queue.#
Options
Show answer
RabbitMQ producers publish messages to exchanges, not directly to queues. The exchange routes each message to bound queues using bindings and the routing key. Even publishing to a queue by name goes through the default (nameless) direct exchange, which binds every queue under its own name.
In AMQP 0-9-1, a producer always publishes to an exchange. The exchange then routes each message to queues based on bindings and the routing key. Publishing with an empty exchange name only looks like sending straight to a queue. It actually uses the default exchange, a direct exchange that every queue is automatically bound to by its own name.
When several consumers subscribe to the same RabbitMQ queue, each message in that queue is delivered to every consumer.#
Options
Show answer
RabbitMQ consumers sharing one queue do not each receive every message. They compete, and each message goes to a single consumer, by default in round-robin order. To broadcast a copy to every subscriber, give each subscriber its own queue and bind those queues to a fanout (or similar) exchange.
Consumers on the same queue compete for its messages. RabbitMQ hands each message to one consumer, by default in round-robin order, which gives you the work-queue (competing consumers) pattern. If you want every subscriber to get a copy of a message, each one needs its own queue bound to an exchange such as a fanout exchange.
You want a new application to use its own isolated RabbitMQ virtual host /orders. The application user orders_app already exists. Put these steps in the order they must happen.#
Put these in order
Show answer
To set up a RabbitMQ virtual host for an application, first create it with rabbitmqctl add_vhost, then grant the user permissions with set_permissions -p. After that the application can connect to the vhost and declare its queues. Each step needs the one before it: permissions need the vhost to exist, connecting needs permissions, and declaring queues needs an open connection.
You can't grant permissions on a vhost that doesn't exist yet, so the vhost has to be created first. A user can only connect to a vhost they have permissions on, so set_permissions has to come before the application connects. Queues and other resources are declared through a connection that is already open, and they belong to that vhost, so declaring them comes last.
An operator is joining node rabbit@node2 to an existing RabbitMQ cluster whose first node is rabbit@node1. Both nodes already share the same Erlang cookie. Which line contains the bug?#
# run on node2
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@node2
rabbitmqctl start_app
rabbitmqctl cluster_statusShow answer
The bug is on line 4.
rabbitmqctl join_cluster takes the name of a node that is ALREADY in the target cluster, so on node2 it should be rabbitmqctl join_cluster rabbit@node1. Passing the node's own name (rabbit@node2) does not join it to the existing cluster. The other steps are right: stop the app, reset the node, join, start the app again, then check the result with cluster_status.
In RabbitMQ (AMQP 0-9-1), a service needs many threads to publish messages concurrently. What is the recommended way to structure connections and channels?#
Options
Show answer
In RabbitMQ, the recommended setup is one long-lived TCP connection per process, with a separate channel for each thread. Channels are lightweight and multiplexed over that one connection, so they are cheap. Channels should not be shared between threads, because frames can interleave. Opening a connection for each operation wastes resources on repeated handshakes.
Channels are lightweight virtual connections multiplexed over a single TCP connection, so the recommended pattern is a long-lived connection with one channel per thread. Opening a connection for each message wastes resources, because every TCP and AMQP handshake is costly. Sharing one channel across threads is unsafe: frames from different threads can interleave, and most client libraries do not treat channels as thread-safe. Opening and closing a connection per thread on every publish brings back the same handshake cost.
In RabbitMQ (AMQP 0-9-1), what is the difference between a consumer using basic.consume and one using basic.get? Which one should a long-running worker normally use, and why?#
Show answer
basic.consume registers a subscription, so the broker pushes messages to the consumer as they arrive. basic.get is a pull: one synchronous request fetches at most one message, and the client has to keep polling. A long-running worker should use basic.consume. Polling with basic.get wastes round trips and adds latency, and the RabbitMQ docs advise against it.
With basic.consume the broker delivers messages to the consumer whenever they're ready, which is efficient. With basic.get the client sends a request and waits for a reply every time it wants a message. That is slow and burns network and CPU when the queue is often empty, so push-based consumption is the recommended way.
For RabbitMQ nodes to form a cluster, every node must share the same secret string, called the Erlang _____, which is typically stored in a file named .erlang.cookie.#
Show answer
For RabbitMQ nodes to form a cluster, every node must share the same secret string, called the Erlang cookie, which is typically stored in a file named .erlang.cookie.
RabbitMQ nodes and CLI tools authenticate to each other with a shared secret called the Erlang cookie. The cookie is stored in .erlang.cookie, and nodes whose cookies don't match can't talk to each other or form a cluster.
In RabbitMQ (AMQP 0-9-1, current 3.x/4.x broker), which of the following events cause the broker to close only the affected channel while leaving the underlying TCP connection and its other channels open? Select all that apply.#
Options
Pick every one that applies.
Show answer
In RabbitMQ, soft errors close only the channel. These include acking an unknown delivery tag, redeclaring a queue with arguments that don't match (406 PRECONDITION_FAILED), and passively declaring a queue that doesn't exist (404 NOT_FOUND). Missed heartbeats and going over channel_max are connection-level failures, so they close the whole TCP connection and every channel on it.
Soft errors such as PRECONDITION_FAILED (406, including an unknown delivery tag or an inequivalent queue redeclaration) and NOT_FOUND (404, such as a passive declare of a missing queue) are channel-level exceptions: the broker sends channel.close and the connection keeps running. Missed heartbeats make the broker treat the whole TCP connection as dead and close it. Going over channel_max is a connection-level hard error (NOT_ALLOWED/channel error), so the broker closes the entire connection. Clients have to reopen any channel that was closed this way, and this is one reason to isolate risky operations on their own channels.
RabbitMQ 3.13 is running on localhost. The vhosts dev and prod both exist and contain no queues. User app has full configure/write/read permissions (.*) on both. What does this pika 1.3 script print?#
import pika
from pika.exceptions import ChannelClosedByBroker
creds = pika.PlainCredentials('app', 'secret')
def connect(vhost):
return pika.BlockingConnection(
pika.ConnectionParameters('localhost', virtual_host=vhost, credentials=creds))
c = connect('dev')
c.channel().queue_declare('orders', durable=True)
c.close()
out = []
for vh in ['dev', 'prod']:
c = connect(vh)
ch = c.channel()
try:
ch.queue_declare('orders', passive=True)
out.append(f'{vh}:ok')
except ChannelClosedByBroker as e:
out.append(f'{vh}:{e.reply_code}')
c.close()
print(' '.join(out))Show answer
dev:ok prod:404
Each virtual host has its own namespace for queues, exchanges and bindings. The queue orders is declared only in dev. A passive declare just checks whether the queue exists, so in dev it succeeds. In prod there is no queue with that name, even though the name and the broker are the same. The broker closes that channel with 404 NOT_FOUND, and pika raises ChannelClosedByBroker with reply_code 404. So the script prints dev:ok prod:404.
RabbitMQ (AMQP 0-9-1): a consumer sets basic.qos(prefetch_count=10, global=false) and then opens two consumers on the same channel. In RabbitMQ (not the AMQP spec), what does global=false vs global=true scope the limit to, and how many unacked messages can this channel hold?#
Show answer
RabbitMQ reinterprets the global flag. With global=false the limit applies per consumer (each new consumer on the channel gets 10), so this channel can hold up to 20 unacked messages. With global=true the limit is shared by all consumers on the channel. The AMQP spec says false = per channel and true = per connection. RabbitMQ does not support per-connection prefetch.
RabbitMQ intentionally deviates from AMQP 0-9-1 here because a per-channel limit needs coordination across queues, which is expensive. That is why global=false means per-consumer, and a common gotcha is that adding consumers raises the channel's total in-flight count.
Related interview questions
Job market
See rabbitmq salaries and hiring demand from live job postings.
The other 88 questions
This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 88 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.
Free · the whole bank · 100 answers per 30 days, each marked with written feedback