Applying message-ttl server policy to existing queue

904 views
Skip to first unread message

Michał Łęgocki

unread,
Jun 1, 2016, 9:53:55 AM6/1/16
to rabbitmq-users
Hello,
According to rabbitmq documentation (https://www.rabbitmq.com/ttl.html) "When a TTL policy is being applied to a queue which already has messages in it, matching messages will be discarded immediately".
In my scenario i have queue with some messages in it and i want to move them to temporary queue. What im doing is:
  • create new exchange and queue for messages:
    • rabbitmqadmin declare exchange name=temp.exchange type=fanout
    • rabbitmqadmin declare queue name=temp.queue
    • rabbitmqadmin declare binding source=temp.exchange destination=temp.queue
  • set policy on queue with message-ttl:0 and dead letter exchange pointing to temp.exchange
    • rabbitmqadmin declare policy name=temp.disabled pattern=original.queue definition='{"message-ttl":0,"dead-letter-exchange":"temp.exchange"}'
Problem is that even though in my management screen I see policy being applied to queue, existing messages aren't dead lettered and they block new incoming messages from dead lettering.
When I consume them they unblock flow and everything is working fine from now on, but i think this behaviour doesn't confirm what I quoted from documentation above.

Am I doing something wrong or have I misunderstood something?


Michael Klishin

unread,
Jun 1, 2016, 10:16:33 AM6/1/16
to rabbitm...@googlegroups.com
The docs also mention "with some caveats" and link to https://www.rabbitmq.com/ttl.html#per-message-ttl-caveats.

If your goal is to move messages from queue A to B temporarily, I'd use a temporary dynamic Shovel.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Michał Łęgocki

unread,
Jun 2, 2016, 3:44:19 AM6/2/16
to rabbitmq-users
Thank you for your answer.
I've read caveats but i thought it doesn't apply to per-queue TTL. Quote:
"While consumers never see expired messages, only when expired messages reach the head of a queue will they actually be discarded (or dead-lettered). When setting a per-queue TTL this is not a problem, since expired messages are always at the head of the queue."

I will probably use dynamic shovels but still I think that either documentation is not clear or there may be a problem with the way per-queue ttl works.
Reply all
Reply to author
Forward
0 new messages