TTL per message in Rabbitmq amqp

442 views
Skip to first unread message

pritesh dudhatra

unread,
Dec 15, 2016, 5:38:43 AM12/15/16
to rabbitmq-users
Hello I'm using Rabbitmq 3.6.5 ,
currently I'm working on rabbitmq amqp,
so, my question is that how to set ttl  per message in amqp rabbitmq java client library,
i'm using the code snippet which is given below,


 
AMQP.BasicProperties properties = new AMQP.BasicProperties();
properties
.builder().expiration("6000");

but there is no effect means message still resides in the queue after the six(6) second.
what could be the possible reason ?

here ,

properties.setExpiration()

method is deprected.
so please suggest me a solution.

Michael Klishin

unread,
Dec 15, 2016, 8:31:15 AM12/15/16
to rabbitm...@googlegroups.com, pritesh dudhatra
The 2 lines you posted seem OK. Can you post more of your code? I'm not sure how you verify this but messages are discarded
when they reach head of the queue: this is documented.

AMQP.BasicProperties#setXYZ methods are deprecated in favor of a builder class,
AMQP.BasicProperties.Builder but even then they are not going away soon.
> --
> 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 an email to rabbitm...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
MK

Staff Software Engineer, Pivotal/RabbitMQ


KH

unread,
Dec 15, 2016, 8:37:25 AM12/15/16
to rabbitmq-users
Pritesh,
Please refer to, https://www.rabbitmq.com/ttl.html and  https://www.rabbitmq.com/blog/2014/01/23/preventing-unbounded-buffers-with-rabbitmq/. As you are using per-message TTL, RMQ will make sure a consumer does not receive expired messages, but in the use of per-message-ttl, until the messages reach the top of the queue, they will not expire. 
Reply all
Reply to author
Forward
0 new messages