rabbitmq-c TTL setting not working for me - please help

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

rabbitmq-c TTL setting not working for me - please help

ktran0003
I set up a queue via amq.direct exchange with one producer and one consumer.
I used the following code to set up TTL for the consumer:

    amqp_table_t table;
    amqp_table_entry_t entry;
    entry.key = amqp_cstring_bytes("x-message-ttl");
    entry.value.kind = AMQP_FIELD_KIND_I16;
    entry.value.value.i16 = 2000;
    table.num_entries = 1;
    table.entries = &entry;
    amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0,  table);

Then every time I consume a message, I sleep for 5 secs just to delay the consuming rate.
I also have the producer send a message every 1 sec.

However, when I run the producer to produce 20 messages, the consumer will get all 20 messages with 5 sec delay in between.
Should some messages not delivered because of TTL  < 5 sec delay?

Thanks,
-Kim



_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: rabbitmq-c TTL setting not working for me - please help

Michael Klishin-2
On 17 June 2014 at 05:03:54, [hidden email] ([hidden email]) wrote:
> > Then every time I consume a message, I sleep for 5 secs just to  
> delay the consuming rate.
> I also have the producer send a message every 1 sec.
>  
> However, when I run the producer to produce 20 messages, the consumer  
> will get all 20 messages with 5 sec delay in between.
> Should some messages not delivered because of TTL < 5 sec delay?  

They should. Do you use the TTL attribute being set for queues in the management UI? 
--  
MK  

Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: rabbitmq-c TTL setting not working for me - please help

ktran0003
Michael,
I tried to use the TTL attribute via management UI like this:
sudo rabbitmqctl set_policy TTL ".*" '{"message-ttl":4000}' --apply-to queue

And I still got all the messages. None of them was dropped.
The management UI shows for the queue:
Parameters | x-message-ttl: 2000
So my setting is recognized by the broker I guess.

Thanks,
-Kim

On 6/16/2014 6:07 PM, Michael Klishin wrote:

> On 17 June 2014 at 05:03:54, [hidden email] ([hidden email]) wrote:
>>> Then every time I consume a message, I sleep for 5 secs just to
>> delay the consuming rate.
>> I also have the producer send a message every 1 sec.
>>  
>> However, when I run the producer to produce 20 messages, the consumer
>> will get all 20 messages with 5 sec delay in between.
>> Should some messages not delivered because of TTL < 5 sec delay?
> They should. Do you use the TTL attribute being set for queues in the management UI?
> --
> MK
>
> Software Engineer, Pivotal/RabbitMQ

_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: rabbitmq-c TTL setting not working for me - please help

Simon MacMullen-2
On 17/06/2014 5:33PM, Kim Tran wrote:
> And I still got all the messages. None of them was dropped.

Hang on. You originally said:

> Then every time I consume a message, I sleep for 5 secs just to delay
> the consuming rate.

That would mean the broker sent you all the messages straight away, but
your app delayed reading them off the socket. The queue can't expire
messages when they are out for delivery.

So if you want a slow consumer, set basic.qos to a low value (e.g. 1),
that way the broker will only send you one message at a time as you
acknowledge them (you are using acks, right?)

Then you should see the messages expire.

Cheers, Simon

--
Simon MacMullen
RabbitMQ, Pivotal
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: rabbitmq-c TTL setting not working for me - please help

ktran0003
Simon,
Thanks for the hints.  I didn't have the basic.qos to receive one at a
time. That's likely the reason.

So what would happen if I got all the messages straight away but slowly
process them:  the queue would get bigger and bigger over time? and
eventually crash with some socket error?

Thanks,
-Kim


On 6/17/2014 9:39 AM, Simon MacMullen wrote:

> On 17/06/2014 5:33PM, Kim Tran wrote:
>> And I still got all the messages. None of them was dropped.
>
> Hang on. You originally said:
>
>> Then every time I consume a message, I sleep for 5 secs just to delay
>> the consuming rate.
>
> That would mean the broker sent you all the messages straight away,
> but your app delayed reading them off the socket. The queue can't
> expire messages when they are out for delivery.
>
> So if you want a slow consumer, set basic.qos to a low value (e.g. 1),
> that way the broker will only send you one message at a time as you
> acknowledge them (you are using acks, right?)
>
> Then you should see the messages expire.
>
> Cheers, Simon
>

_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: rabbitmq-c TTL setting not working for me - please help

Matthias Radestock-3
On 17/06/14 17:59, Kim Tran wrote:
> So what would happen if I got all the messages straight away but slowly
> process them:  the queue would get bigger and bigger over time? and
> eventually crash with some socket error?

No, the 'queue' (if by that you mean the RabbitMQ broker) won't crash.
See http://www.rabbitmq.com/memory.html

Matthias.
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss