1

Hello Friends i want to know about the expriation Property in RabbitMQ. And what happens if I do not set this property. I am new in rabbitMQ please help me.

AMQP.BasicProperties properties = new AMQP.BasicProperties();
properties.setExpiration("432000000");
Vidya Sagar
  • 1,699
  • 3
  • 17
  • 28
anil
  • 13
  • 5

1 Answers1

4

Read this https://www.rabbitmq.com/ttl.html

A TTL can be specified on a per-message basis, by setting the expiration field in the basic AMQP class when sending a basic.publish.

The value of the expiration field describes the TTL period in milliseconds. The same constraints as for x-message-ttl apply. Since the expiration field must be a string, the broker will (only) accept the string representation of the number.

Suppose you set Expiration time = 1000

If no one consumes the message within 1 second the message will be dropped.

You can handle the "dropped" messages using https://www.rabbitmq.com/dlx.html.

if you don't set the Expiration the message remains to the queue for ever (if there aren't consumers).

EDIT

Added the comment by theMayer

The messages are not dropped until they reach the head of the queue - therefore, if a non-expiring message exists prior to the message in the queue, no messages will self-delete until the non-expiring message is consumed.

read also this post

Community
  • 1
  • 1
Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52
  • 2
    This is true with a caveat. The messages are not dropped until they reach the head of the queue - therefore, if a non-expiring message exists prior to the message in the queue, no messages will self-delete until the non-expiring message is consumed. – theMayer Jun 23 '15 at 20:41