Phill Pafford
Phill Pafford

Reputation: 85318

Set Message TTL to one hour RabbitMQ

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

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

What I've tried:

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}}

Upvotes: 6

Views: 12360

Answers (2)

Eric Leschinski
Eric Leschinski

Reputation: 153963

I can set the queue message time to live from the rabbitmq management console like this:

  1. I'm using RabbitMQ 3.1.5 on Fedora Linux, visit this in the browser:

    http://your_rabbitmq_server.com:15672

  2. Click "Queues" tab and scroll down to where it says: "Add a new queue"

  3. Under the subsection: "Add a new queue", fill out these text boxes:

    Virtual host:             /
    Name:                     myqueue1
    Durability:               Durable
    Auto delete:              No
    Message TTL:     
    Auto expire: 
    Max length: 
    Dead letter exchange:
    Dead letter routing key: 
    
    Argument key      = x-message-ttl
    Argument value    = 3600000
    Argument datatype = number
    
  4. Click OK to save it.

Now I could consume from the queue and the message will still be there for the specified time.

Upvotes: 1

james_t
james_t

Reputation: 2733

queue_options:    {name: 'blah_queue', arguments: {'x-message-ttl' : ['I', '3600000']}}

Upvotes: 1

Related Questions