RabbitMQ: What is the default x-message-ttl value

Martin Chen picture Martin Chen · Jul 25, 2014 · Viewed 21.1k times · Source

I couldn't find in RabbitMQ documentation the default x-message-ttl value comes with the installation.

I know how to set it to a desired value but I am curious to know the default value.

Answer

pinepain picture pinepain · Jul 25, 2014

There are no x-message-ttl argument set by default from the broker side, so basically you can interpret default value as infinity.

If you publish message without ttl to queue without ttl set (yupp, there are per-message and per-queue ttl arguments, see note below):

  • if message published as persistent and queue declared as persistent message will stay in queue as long as it will not be consumed;

  • if message was not published as persistent or queue was not declared as persistent, then message will stay in queue as long as it will not be consumed or until broker restart.

TTL note:

When both per-message and per-queue ttl set broker use the minimal vale. For example, if per-message ttl is 10000 (10 sec) and per-queue ttl is 20000 (20 sec) then per-message ttl will applied.

Per-message TTL note:

Messages with expired ttl will stay in queue as long as they not reached queue head. Don't worry, they will not be send to consumer, but they will take some resources until they reach head. This is how RabbitMQ queues works (they stick to FIFO idea, which is sometimes may break strict compatibility with AMQP protocol). See Caveats section in Time-To-Live Extensions for more.