5

如何设置消息 TTL(不是队列)

  • 交换(交换发送到多个队列)
  • 消息(发布消息时)
  • 队列(在队列本身上,但同样这是消息 TTL,而不是队列 TTL)

我正在运行 RabbitMQ 3.x、Symfony 2.1.x 和RabbitMqBundle

我试过的:

  • 当我从 RabbitMQ Admin UI 创建队列时设置消息 TTL

我将消息属性设置为'x-message-ttl' => 3600000. 在 RabbitMQ 配置中,它看起来像这样:

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

这是我得到的错误:

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

我尝试在 config.yml ( symfony / https://github.com/videlalvaro/RabbitMqBundle / README )中设置

这给捆绑包使用的 AMQP 库带来了一堆错误。

我尝试修改 AMQP 库本身以允许x-message-ttl消息属性,但出现异常Error sending data

有没有人使用 RabbitMQBundle 设置消息 TTL?

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

2 回答 2

1
queue_options:    {name: 'blah_queue', arguments: {'x-message-ttl' : ['I', '3600000']}}
于 2013-01-16T21:06:06.827 回答
1

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.

于 2014-09-10T14:15:02.730 回答