Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMq: Change x-message-ttl of a queue

Tags:

rabbitmq

How can I implement a queue with configurable x-message-ttl?

I have a queue with x-message-ttl set to 1 minute and I want to change it to 2 minute at runtime. How can this be achieved?

I already tried declaring queue again with x-message-ttl = 2 minutes but neither ttl is changing by this nor message is being published.

like image 212
ctor Avatar asked Feb 13 '17 11:02

ctor


1 Answers

if you create a queue with arguments x-message-ttl you can't change it, you have to remove and recreate the queue.

but you can use the policies:

  1. Create queues without ttl arguments
  2. create the policy, for example:rabbitmqctl set_policy expiry ".*" "{""expires"":1800000}" --apply-to queues

In this way you can change the queue TTL value

like image 57
Gabriele Santomaggio Avatar answered Nov 09 '22 22:11

Gabriele Santomaggio