Search Tutorials


Top RabbitMQ (2021) frequently asked interview questions | JavaInUse

Top RabbitMQ frequently asked interview questions.

In this post we will look at RabbitMQ Interview questions. Examples are provided with explanations.


  1. What is Messaging?
  2. What is RabbitMQ?
  3. What is Advanced Message Queuing Protocol (AMQP)?
  4. What is an exchange in RabbitMQ?
  5. What is routing key in RabbitMQ?
  6. What is Erlang ? Why is it required for RabbitMQ?
  7. How to install RabbitMQ?
  8. How to integrate RabbitMQ with Spring Boot?
  9. What is Spring Cloud Stream? What is the need for it?
  10. What are the types of exchanges available in RabbitMQ?
  11. How to verify RabbitMQ version?
  12. How to delete all RabbitMQ queues?
  13. Does RabbitMQ have any concept of message priority?
  14. What is STOMP?
  15. How to implement Chat Application using Spring Boot + WebSocket + RabbitMQ?
  16. How to implement Retry and Error Handling for RabbitMQ?
  17. How to consume messages from RabbitMQ using Spring Boot?
  18. What is a Dead Letter Queue?

What is Messaging?

Messaging is a communication mechanism used for system interactions. In software development messaging enables distributed communication that is loosely coupled. A messaging client can send messages to, and receive messages from, any other client. The structure of message can be defined as follows-
Message Structure

What is RabbitMQ ?

RabbitMQ is an open source message broker software (sometimes called message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover.


What is Advanced Message Queuing Protocol (AMQP) ?

The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for message-oriented middleware. AMQP 0-9-1 is a binary messaging protocol and semantic framework for microservices and enterprise messaging. RabbitMQ is based on AMQP 0-9-1 Protocol. RabbitMQ supports -
  • AMQP 0-9-1
  • AMQP 1.0
  • MQTT
  • STOMP
  • HTTP
RabbitMQ Messaging Flow- Bindings are what connects the exchanges to queues.
RabbitMQ Message Flow

What is an exchange in RabbitMQ?

An exchange accepts messages from the producer application and routes them to message queues with help of header attributes, bindings, and routing keys. A binding is a "link" that you set up to bind a queue to an exchange.

What is routing key in RabbitMQ?

The routing key is a message attribute. The routing algorithm behind a direct exchange is simple - a message goes to the queues whose binding key exactly matches the routing key of the message.


What is Erlang ? Why is it required for RabbitMQ ?

Erlang is a general-purpose, concurrent, functional programming language, as well as a garbage-collected runtime system. The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover. Since RabbitMQ is built on top of Erlang, we will first need to install Erlang beforing installing RabbitMQ

How to install RabbitMQ?

Install RabbitMQ on Windows

How to integrate RabbitMQ with Spring Boot?

Spring Boot + RabbitMQ Example


What is Spring Cloud Stream? What is the need for it?

In previous examples we had implemented examples for integrating Spring Boot Applications with Messaging Systems like Apache Kafka and RabbitMQ. If you look at these examples these required a lot of configuration code which was Broker specific. For example in case of RabbitMQ integration with Spring Boot we had to write code to create AmqpTemplate Template and Bindings. So if tomorrow the Messaging System changes we will also need to make application code changes.
Spring Cloud helps solve this problem using Spring Cloud Stream. Using Spring Cloud Stream we can develop applications where we do not need to specify the implementation details of the messaging system we want to use. We just need to specify the required binding dependencies and Spring Cloud Stream will the integrate the messaging systems to Spring Boot Application.
Spring Cloud Stream Tutorial
Spring Cloud Stream Tutorial - Publish Message to RabbitMQ Simple Example
Spring Cloud Stream Tutorial - Consume Message from RabbitMQ Simple Example

What are the types of exchanges available in RabbitMQ?

There are 4 types of exchanges available in RabbitMQ.
  • Direct - Based on the routing key a message is sent to the binding queue having the same routing key. The routing key of exchange and the binding queue have to be an exact match.
    Direct Exchange type
  • Fanout - The message is routed to all the available bounded queues. The routing key if provided is completely ignored. So this is a kind of publishe-subscribe design pattern.
    Fanout Exchange type
  • Topic - Here again the routing key is made use of. But unlike in direct exchange type, here the routing key of the exchange and the bound queues should not necessarily be an exact match. Using regular expressions like wildcard we can send the exchange to multiple bound queues.
    Topic Exchange type
  • Headers - In this type of exchange the routing queue is selected based on the criteria specified in the headers instead of the routing key. This is similar to topic exchange type, but here we can specify complex criteria for selecting routing queues.
    Headers Exchange type


How to verify RabbitMQ version?

sudo rabbitmqctl status


How to delete all RabbitMQ queues?

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app


Does RabbitMQ have any concept of message priority?

RabbitMQ does have concept of priority-
  • We can define the queue's priority range at the time the queue is created
  • Messages where priority is not set get a priority of 0
  • Messages with a numeric priority higher than the maximum set on the queue get the highest priority the queue supports

What is STOMP?

STOMP is a simple text-oriented messaging protocol used by our UI Client(browser) to connect to enterprise message brokers.
Clients can use the SEND or SUBSCRIBE commands to send or subscribe for messages along with a "destination" header that describes what the message is about and who should receive it.
It defines a protocol for clients and servers to communicate with messaging semantics. It does not define any implementation details, but rather addresses an easy-to-implement wire protocol for messaging integrations. The protocol is broadly similar to HTTP, and works over TCP using the following commands:
  • CONNECT
  • SEND
  • SUBSCRIBE
  • UNSUBSCRIBE
  • BEGIN
  • COMMIT
  • ABORT
  • ACK
  • NACK
  • DISCONNECT

Spring Boot Websocket Chat STOMP Architecture

How to implement Chat Application using Spring Boot + WebSocket + RabbitMQ?

Build a Chat Application using Spring Boot + WebSocket + RabbitMQ
Build a web chat using Spring Boot and WebSocket.

How to implement Retry and Error Handling for RabbitMQ?

Spring Boot + RabbitMQ Tutorial - Retry and Error Handling Example
In this tutorial we will be implementing a Spring Boot + RabbitMQ example to retry messages on exception and if exception still exists after maximum retries then put message in a dead letter queue where it can be analyzed and corrected later.

How to consume messages from RabbitMQ using Spring Boot?

To consume message from a RabbitMQ Queue we need to implement RabbitMQ listeners using Spring Boot.
Spring Boot + RabbitMQ Application to consumer message
Spring Boot + RabbitMQ Tutorial - Configure Listeners to consume messages

What is a Dead Letter Queue?

In English vocabulary Dead letter mail is an undeliverable mail that cannot be delivered to the addressee. A dead-letter queue (DLQ), sometimes which is also known as an undelivered-message queue, is a holding queue for messages that cannot be delivered to their destinations due to some reason or other.
According to Wikipedia page - In message queueing the dead letter queue is a service implementation to store messages that meet one or more of the following failure criteria:
  • Message that is sent to a queue that does not exist.
  • Queue length limit exceeded.
  • Message length limit exceeded.
  • Message is rejected by another queue exchange.
  • Message reaches a threshold read counter number, because it is not consumed. Sometimes this is called a "back out queue".
Later on we can analyze the messages in the DLQ to know the reason why the messages are failing.
Dead Letter Queue Tutorial

See Also

Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions