[rabbitmq-discuss] RabbitMQ 3.0.0 & Expiration & STOMP

Tim Watson tim at rabbitmq.com
Tue Nov 20 14:11:42 GMT 2012


Hi Lionel,

This is, in fact, a bug in the per-message TTL implementation (and has nothing to do with STOMP specifically). We've logged an issue and are actively fixing it at the moment. Currently we only expire messages when consuming *starts*, but since we generally dequeue messages faster than enqueue them, the problem you've stumbled upon was hardly noticeable in the past. A fix for this will be made available in the next bugfix release.

Thanks for reporting this!

Cheers,
Tim

On 20 Nov 2012, at 09:19, Lionel Cons wrote:

> Reading http://www.rabbitmq.com/ttl.html and http://www.rabbitmq.com/stomp.html,
> it seems that per-message TTL is now supported, even with STOMP.
> 
> I've tried to use expiration but it does not work as expected. Here is my
> test case (see attached):
> - send two messages in a queue, one with 3s TTL, the other one with 30s
> - wait 5s
> - connect and drain the queue
> 
> In my test I receive both messages, even the one which should have expired.
> 
> Any hint on why it does not work as expected?
> 
> Cheers,
> 
> Lionel
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use Net::STOMP::Client qw();
> 
> use constant HOST        => "localhost";
> use constant PORT        => 6163;
> use constant DESTINATION => "/queue/test";
> use constant USER        => "guest";
> use constant PASSWORD    => "guest";
> 
> # uncomment the next line to see more...
> #$Net::STOMP::Client::Debug::Flags = -1;
> 
> sub stomp () {
>    my($stomp);
> 
>    $stomp = Net::STOMP::Client->new(host => HOST, port => PORT);
>    $stomp->connect(login => USER, passcode => PASSWORD, host => "/");
>    return($stomp);
> }
> 
> sub test () {
>    my($prod, $cons, $frame, $count);
> 
>    # connect
>    $prod = stomp();
> 
>    # send test messages
>    $prod->send(
> 	destination => DESTINATION,
> 	body => "Hello ancient world (30s)",
> 	expiration => 30000,
>    );
>    $prod->send(
> 	destination => DESTINATION,
> 	body => "Hello ancient world (3s)",
> 	expiration => 3000,
>    );
> 
>    # disconnect
>    $prod->disconnect(receipt => $prod->uuid());
> 
>    # sleep a bit
>    sleep(5);
> 
>    # connect
>    $cons = stomp();
> 
>    # subscribe
>    $cons->message_callback(sub { return(1) });
>    $cons->subscribe(
> 	destination => DESTINATION,
> 	id          => $cons->uuid(),
> 	receipt     => $cons->uuid(),
>    );
>    $cons->wait_for_receipts(timeout => 3);
>    die("no receipts received!") if $cons->receipts();
> 
>    # wait for messages
>    $count = 0;
>    while (1) {
>        $frame = $cons->wait_for_frames(timeout => 3);
>        last unless $frame;
>        $count++;
>    }
>    printf("received %d: %s\n", $count, $count == 1 ? "OK" : "BAD");
> 
>    # disconnect
>    $cons->disconnect();
> }
> 
> test();
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss



More information about the rabbitmq-discuss mailing list