RabbitMQ Queues in Detail

What is Queue:

Queue is buffer to store incoming messages which were sent from exchange to queue.

How to create RabbitMQ queue step by step:

Let’s see how to create queues in RabbitMQ steps by steps using RabbitMQ web management console.

Open URL in Browser: http://localhost:15672 you will get following login screen.

RabbitMQ Login

Click on Queues Tab as shown below:


Click On Add a new queue and enter respective as  shown below:


Now click on Add queue button and queue:


Explanation of RabbitMQ Queues properties:

  • Name
    • Set unique name for exchange.
  • Durability
    • Message will survive even post restarting of server and these data will be stored in server memory.
      • Durable: Message will survive even post restarting of server and these data will be stored in server memory.
      • Transient: In this case message will be deleted after restarting of server.
  • Auto Delete
    • Yes/No
      • If your queue is exclusive then this attribute has no effect because as soon as client disconnect (connection lost) from queue it will be auto deleted.
  • Arguments
    • Actually in RabbitMQ arguments are optional and it is used for Plugins and Broker Specified features

Following are the list of arguments values which can be used as per your requirement:

  • Time-to-live (TTL) Argument
  • Auto expire Argument
  • Max Length Argument
  • Max Length Bytes Argument
  • Overflow Behavior Argument
  • Dead Letter Exchange Argument
  • Dead Letter Routing Key Argument
  • Maximum Priority Argument
  • Lazy Mode Argument
  • Master locator argument:

Time-to-live (TTL) Argument:

We will set a time span to queue and it’ll be discarded if it reaches defined time span. Here, we will set time in milliseconds.

x-message-ttl: 240000 (note: 1 Minutes = 60000 milliseconds)

Refer below sample for the same:


Auto expire Argument:

Set an expiry time to queue and it is defined for how long a queue is unused before it is deleted automatically.


Refer below sample for the same:


Max Length Argument

This argument basically defines how many ready messages can be there in queue before it drop them from head.

x-max-length = 10

A bit confusing right? Let’s understand by simple example. Consider we have set x-max-length = 10, and we have published 11 messages in queue. As we already set max length is 10 then there will be only 10 messages in queue and the oldest one will be deleted automatically.

Refer below sample for the same:


Max Length Bytes Argument:

Here we set total body size for ready messages a queue can contain before it starts to drop them from its head.

x-max-length-bytes = 1000000 (1 MB)

Example: If we set value x-max-length-bytes = 1000000 (1 MB) and if you publish messages in queue and also the queue size increase over 1 MB then the oldest are going to be deleted from the queue.


Overflow Behavior Argument:

This argument determines what happens to messages when the most length of a queue is reached.

It can have only following values:

  • drop-head
  • reject-publish

Refer below sample for the same:




Dead Letter Exchange Argument:

Here we will set an optional name for exchange to which messages are going to be republished if they’re rejected or expire.
image for dead letter.

Refer below sample for the same:


Dead Letter Routing Key Argument

Optional replacement routing key are going to be used when a message is dead-lettered. If this is often not set, then the message’s original routing key are going to be used.

Let’s understand by Example:
If we published message to an exchange with routing key “routing.key1” which message is dead-lettered. Then this message will be published to dead-lettered exchange with routing key “routing.key1”.

Refer below sample for the same:


Maximum Priority Argument:

We will set a maximum number of priority levels for the queue to support. In case, if we didn’t set (“x-max-priority“) argument, then the queue won’t support message priorities. To declare a priority queue, we’d like to use x-max-priority optional queue argument.

Here argument value should be positive integer between 1 and 255.

Refer below sample for the same:



Lazy Mode Argument:

We will set the queue into a lazy mode, keeping as many messages as possible on disk to scale back the RAM usage.

Refer below sample for the same:


Master locator argument:

We will set the queue into master location mode to see the rule by which the queue master is found when declared on a cluster of nodes.

Refer below sample for the same:


Reference: Master Locator argument

Finally, we have completed all the properties of RabbitMQ queue

Next Step: RabbitMQ Bindings:

%d bloggers like this: