Search code examples
rabbitmqamqp

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


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.


Solution

  • There is 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 value. 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 sent to consumer, but they will take some resources until they reach head. This is how RabbitMQ queues works (they stick to FIFO idea, which sometimes may break strict compatibility with AMQP protocol). See Caveats section in Time-To-Live Extensions for more.