Set Message TTL to one hour RabbitMQ

Phill Pafford picture Phill Pafford · Jan 16, 2013 · Viewed 8.3k times · Source

How can I set the message TTL ( Not the Queue ) from either the

  • Exchange ( The exchange sends to multiple queues )
  • Message ( when publishing the message )
  • Queue ( On the queue itself but again this is the Message TTL and not the Queue TTL )

I'm running RabbitMQ 3.x, Symfony 2.1.x and the RabbitMqBundle.

What I've tried:

  • Setting the Message TTL when I make the queue itself from the RabbitMQ Admin UI

I set the message properties to 'x-message-ttl' => 3600000. In the RabbitMQ config it looks like this:

{
    "name": "blah_queue",
    "vhost": "foobar",
    "durable": true,
    "auto_delete": false,
    "arguments": {
            'x-message-ttl' => 3600000
    }
},

this is the error I get:

PRECONDITION_FAILED - inequivalent arg 'x-message-ttl'for queue

I tried setting in the config.yml ( symfony / https://github.com/videlalvaro/RabbitMqBundle / README )

this gives a bunch of errors with the AMQP library the bundle uses.

I tried modifying the AMQP library itself to allow the x-message-ttl message properties and I get an exception Error sending data.

Has anyone set the Message TTL using the RabbitMQBundle?

queue_options:    {name: 'blah_queue', arguments: {'x-message-ttl' => 3600000}}

Answer

james_t picture james_t · Jan 16, 2013
queue_options:    {name: 'blah_queue', arguments: {'x-message-ttl' : ['I', '3600000']}}