Top 50 RabbitMQ Interview Questions & Answer

RabbitMQ interview questions and answers

Table of Contents

1) What is RabbitMQ?

RabbitMQ is an open-source message-broker software is also known as message queueing technology. It defines queues to which applications communicate for data transfer, or message transmission. Any kind of information could be included in a message. This message is processed by the recipient application.

2) When and why to use RabbitMQ?

Message queueing is useful when you want to exchange a message for consumption or for balance of loads between workers with multiple recipients. The user is able to take a message from the queue while the producer is in the queue, and start processing. The consumer can be on a different server or on the same server than the publisher. The requested application can be of one language and the consumer application is of other language – the message broker would not care about the application languages, it just send messages between consumer and reciever. Which also reduces the dependencies or coupling between the application.

3)What Is binding And routing Key?

A binding is a “bridge” that you set up to connect a queue to an exchange.
The routing key is an attribute message that the exchange examines when determining how to route the message to queues.

4)What is a RabbitMQ channel?

They enable you to have a single connection to the RabbiMQ server, but for different parts of your application they have sandboxed communication. Channels are how the RabbitMQ server communicates with your application. It hold one connection (instance) per client process and many channels in that process (instance)

5) What is a dead letter queue in rabbitmq?

In general, a death letter queue (DLQ), also referred to as an undelivered-message queue, is a holding queue of messages that can not be sent to their destinations for some reason.
In rabbitmq, the dead letter queue is service implementation to store messages that satisfy 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”.

6)How to implement RabbitMQ retry mechanism?

Whenever any data in the message is transmitted that the receiver does not accept, or when a message is sent to a queue that does not exist. The message is retried and sent up to a set number of times. Even if the communication is not received by the recipient but is sent from the sender’s end. Now In such instances, the message queue is marked as undeliverable or deadLetter queue.

7)What is Exchange?

Messages are not posted directly in the queue; rather, the user sends messages to the exchange. An exchange is responsible for routing the messages to the various queues. An exchange receives messages from the producer request and routes them by bindings and routing keys to message queues. A binding is a linkage between an exchange and a queue.

8)Which Protocol RabbitMQ uses?

RabbitMQ uses Advanced Message Queuing Protocol (AMQP). Its an open standard layer used to communicates date across network by means of byte stream.

9) What is RabbitMQ Vhost?

A Virtual Host (a.k.a. ‘ vhost ‘) in AMQP is a namespace for objects such as Exchanges, Queues and Bindings. RabbitMQ utilizes more concrete implementation of virtual hosts, through effectively making them “virtual clusters” on top of the broker.

10) How RabbitMQ differs from ActiveMQ?

RabbitMQ is open source message broker with support for several protocols, written in Erlang. Whereas ActiveMQ is also open source with support for several protocols, written in Java langauge.

11) Is RabbitMQ support MQTT (Message Queue Telemetry Transport)?

RabbitMQ supports MQTT 3.1.1 through a plugin that ships to the core distribution.
Supported MQTT Features:

  • QoS0 and QoS1 publish & consume
  • QoS2 publish (downgraded to QoS1)
  • TLS
  • Session stickiness
  • Retained messages with pluggable storage backends
  • Last Will and Testament (LWT)

12) Is RabbitMQ persistent?

Having a queue durable is not same as making persistent messages. Messages can be distributed either with making mode to persistent or transient. When you post your message, you need to set the delivery mode to persistent if you want it to remain in your long-lasting queue during restart.

13) Is RabbitMQ uses database?

RabbitMQ intentionally does not store messages in a database. RabbitMQ writes messages to disk in below two ways:
Messages published in delivery_mode=2
Memory pressure causes RabbitMQ to run out of RAM and transfers messages to the disk to free up RAM.

14) Does RabbitMQ is PUSH or PULL?

RabbitMQ uses a PUSH template and prevents exhausting consumers through the prefetch configured limit. PULL is used by Kafka, where consumers request for messages from a particular offset batches.

15) What is Dead Letter Exchange in Rabbitmq?

If there is no appropriate queue for the message, the message will be dropped quietly. RabbitMQ offers an AMQP extension known as the “Dead Letter Exchange”. The dead letter exchange provides features for collecting non-deliverable messages.

16) 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.

17) 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.

18) 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

19) 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.

20) Why choose RabbitMQ?

There are many on the market now MQ You can choose , such as ActiveMQ、ZeroMQ、Appche Qpid Why choose RabbitMQ?

except Qpid,RabbitMQ Is the only one that has achieved AMQP Standard message server
reliability ,RabbitMQ Persistence support for , It ensures the stability of the message
High concurrency ,RabbitMQ Used Erlang development language ,Erlang It’s a language developed for telephone switches , Born with a high and luminous ring , And high availability features
Cluster deployment is simple , It should be Erlang bring RabbitMQ Cluster deployment becomes super simple
High community activity , According to the information on the Internet ,RabbitMQ It’s also the first choice.

21) What are the different types of exchange types in RabbitMQ?

RabbitMQ has following types of Exchanges-
Direct helps in transfering the messages to the queues on the basis of message routing key.
Fanout helps in sending messages to all the queues that are linked with it.
Topic helps in exhanging matches between the routing key and the binding routing pattern.
Headers helps in exchanging the routing attributes of the message headers.

22) How to delete all queues in RabbitMQ ?

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app

23) What is Exchange?

Messages is not posted directly in the queue, the user sends messages to the exchange, it is responsible for routing the messages to the queues.Exchange helps in receiving messages from the producer request and routes them by bindinga and routings keys for messaging queues.
It acts like a bindage, linking between an exhange and a queue.

24) Which Protocol RabbitMQ uses?

RabbitMQ uses AWQP(Advanced Message Queuing Protocol) that is an open standard layer and uses to communicate date across network by means of byte stream.

25) What is a Server in Rabbitmq?

RabbitMQ Servers are robust and scalable implementation of AMQP broker, it helps in displaying a banner messages and reports on the progress in the startup sequence with the message Broker Running, that indicates the RabbitMQ broker has been started successfully.

26) What ports does RabbitMQ use?

RabbitMQ Management console:
PORT 15672 for RabbitMQ version 3.x
PORT 55672 for RabbitMQ pre 3.x

SERVER_ERL_ARGS=”+K true +A30 +P 1048576 \
-kernel inet_default_connect_options [{nodelay,true}] \
-kernel inet_dist_listen_min 35197 \
-kernel inet_dist_listen_max 35197″

27) How can we verify RabbitMQ version?

sudo rabbitmqctl status

28) What is ZeroMQ?

ZeroMQ is an asynchronous messaging library and is developed by iMatrix to be used in distributed applications.It uses sockets for carrying atomic messages across various transport like in process, inter-process, TCP, and multicast.
It is written in C++, ZeroMQ is developed by a large community of contributors.

29) How do we stop the RabbitMQ server on localhost?

sudo -u rabbitmq rabbitmqctl stop

30) How to restart RabbitMQ service?

We can restart it like any other service:
sudo service rabbitmq-server restart

We get a specific control interface as well:
sudo rabbitmqctl “report”
sudo rabbitmqctl “reset”

31)2) Enlist major features RabbitMQ?

Some of the major features of RabbitMQ are,

RabbitMQ supports Asynchronous messaging with multiple messaging protocols, multiple exchange types, flexible routing, message queuing, and delivery acknowledgment.
It has support for Distributed deployment to deploy as clusters for high-availability and throughput.
With RabbitMQ, you get a diverse array of tools and plugins to support continuous integration, operational metrics, and integration to other enterprise systems.
It provides HTTP-API, command-line tool, and GUI based tool for managing and monitoring RabbitMQ.
It is Enterprise and Cloud-ready as it is easy to deploy in public and private clouds with support for pluggable authentication, authorization, and TLS & LDAP support.
Support for many popular programming languages such as Java, .Net, PHP, Python, JavaScript, Ruby, Go, and many others.

32) Enlist types of exchanges available in RabbitMQ?

There are four types of exchanges available in RabbitMQ. They are

Direct Exchanges – This type route the messages with a routing key equal to the routing key declared by the binding queue.

Fanout Exchanges – This type route the messages to all bound queues indiscriminately.

Topic Exchanges – This type route the messages to the queues if the routing key of the route is matched all or a portion of the matching patterns.

Headers Exchanges – This type route the messages based upon the matching of message headers to the expected headers which are specified in the binding queue.

33) List some client Libraries supported by RabbitMQ?

Some of the client libraries supported by the RabbitMQ are,

RabbitMQ Java Client
RabbitMQ JMS Client
RabbitMQ .NET Client – supports .NET Core and .NET 4.5.1+
RawRabbit – Higher-level client which targets ASP.NET vNext and .NET Core
Bunny – RabbitMQ Ruby Client
March Hare – JRuby RabbitMQ Client
Pika & aio-pika – a pure Python Client
Aio-amqp – an asynchronous Python Client
Php-amqplib – Fully featured PHP RabbitMQ Client
Amqp.node – RabbitMQ Client for Node JS
Lapin & amiquip – RabbitMQ Client for rust

34) What is Spring Cloud Stream?

Spring Cloud Stream is a framework for building highly-scalable event-driven microservices that are connected with the shared messaging systems. It provides a flexible programming model that is built on already established Spring idioms. It includes support for persistent pub/sub semantics, consumer groups, and stateful partitions. The core building blocks of the Spring Cloud Stream are the Destination Binders, Destination Bindings, and Message.

35) How to verify the version in RabbitMQ?

To check for the version of the RabbitMQ installed. Type the command “sudo rabbitmqctl status” in your shell. Then, check for the line which looks like “{rabbit, “RabbitMQ”, “2.6.1”},”. Here, you can verify the version of the RabbitMQ installed in your system.

36) What is STOMP?

STOMP (Simple Text Oriented Messaging Protocol) is used to provide a format for communication between the STOMP clients with the STOMP message brokers. This easy messaging interoperability is supported in many languages, platforms, and brokers. Using STOMP, you can write a client within a couple of hours as it is easy to design. RabbitMQ has support for STOMP through the plugin that ships in the core distribution.

This plugin supports STOMP versions 1.0 through 1.2.

37) What is the routing key in RabbitMQ?

The message structure in the RabbitMQ is divided into two parts. They are the payload and routing key.

The routing key is used to describe the payload passed by the system and the messaging system itself to determine who will be the receiver of the payload. The routing key also enables you to bind queues to exchanges to deliver the message to the queue based on the four types of exchanges.

38) List the design patterns used by RabbitMQ?

Some of the architectural patterns used by the RabbitMQ are,

One-Message-to-One-Consumer Model

This model is used to deliver each task to exactly one worker. The exchange types of this pattern are,

Round-Robin – In this patter, the RabbitMQ dispatches each message to the next consumer in the sequence.
Next Available Worker – In this type, the RabbitMQ won’t give more than one message to a worker at a time.
One-Message-to-Multiple-Consumers Model

In this model, one message is dispatched to multiple consumers. Some exchange types of this pattern are,

Publish/Subscribe – In this patter, a producer sends a message to a set of subscribed consumers.

39) MQ What are the disadvantages?

Reduced system availability , Dependence on the outside
You need to consider MQ Lost message , The problem of repeated consumption
It takes effort to ensure the order of messages , Uniformity

40) MQ How to avoid message piling up

Increase the consumption rate ( The way of clustering )
Consumers obtain messages in batches for consumption

41) MQ How to ensure that messages are not lost

Message confirmation mechanism
Persistence
news ACK

42) MQ What is the push and pull architecture model?

MQ After the server establishes a long connection with the consumer ,MQ The server will actively push data to consumers
When consumers start for the first time , Will go to MQ The server pulls data

43) producer Producer And consumers Consumer What are the knowledge points ?

producer

Message producer , Deliver a message
A message generally consists of two parts : Message body (payload) And labels (Label)
consumer

News consumption , receive messages
Consumer connected to RabbitMQ The server , And subscribe to the queue

When consuming a message, only the message body is consumed , Drop the label

44) How persistence works?

Rabbit The persistent message is written to the persistent log file on disk , After the news is consumed ,Rabbit This message will be identified as waiting for garbage collection.

45) RabbitMQ The queue structure of?

rabbit_amqqueue_process
Responsible for protocol related message processing , That is, receiving messages from producers 、 Delivering messages to consumers 、 Process message confirmation, etc

backing_queue
It’s the concrete form and engine of message storage , And to rabbit_amqqueue_process Provide the relevant interface for calling

46) When the switch cannot find a qualified queue based on its own type and routing key , How do you deal with that?

When we set parameters for the switch , There is a sign called mandatory

When mandatory The flag bit is set to true when
If exchange According to their own types and messages routingKey Can’t find a suitable queue Store messages , that broker Will call basic.return Method to return the message to the producer

When mandatory Set to false when
The preconditions are consistent with the above , here broker Will discard the message directly

47) What are the types of nodes in the cluster?

Memory nodes
ram, Write changes to memory .

Disk nodes
disc, Disk write operation

RabbitMQ in requirement At least one disk node

48) How to ensure RabbitMQ High availability of message queues?

RabbitMQ There are three modes to ensure :

standalone mode
It is usually started locally , Learn and test by yourself , Will not be used in production environments

Common cluster mode
Start multiple… On multiple machines RabbitMQ example , Each machine starts one

Mirror cluster mode
RabbitMQ High availability mode of

Unlike the normal cluster model , Created queue, Regardless of metadata ( Metadata means RabbitMQ Configuration data of ) still queue The message in the message directory will exist on multiple instances ,

Then every time I write a message to queue When , Will automatically send messages to multiple instances queue Message synchronization in

49) What is Fanout Exchange ?

Fanout exchange routes the messages to all queues which are bound to it. Say if there are 5 queues bound to Fanout Exchange then when message comes to Fanout Exchange it will go to all 5 queues. It is kind of publish-subscribe.

50) What is binding ?

It is link OR connection between exchange and queue. For exchange to route the message to particular queue that queue should be bound to exchange with routing key or headers.

Related video:

Rajesh Kumar
Follow me
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x