[rabbitmq-discuss] redelivery after ACK
larry.edelstein at therealreal.com
larry.edelstein at therealreal.com
Thu Nov 8 22:18:14 GMT 2012
When I run a capture with Wireshark and consume/ack a few messages, I see the expected traffic, but no acks.
However: when I set channel.prefetch(1), now I see the acks. If I kill and restart the consumer, delivery begins with the first un-ack'd message, as I'd expect.
In fact, if I set channel.prefetch(..) to n, and kill/restart the consumer after n+1 messages have been received and ack'd, delivery resumes with the first un-ack'd message.
And if I issue a queue.unsubscribe, then kill and restart, delivery resumes with un-ack'd messages.
Have I misunderstood the way RabbitMQ and/or the gem are supposed to behave? I really thought an ack was an ack.
-larry
-----Original Message-----
From: larry.edelstein at therealreal.com
Sent: Thursday, November 8, 2012 11:36am
To: "Simon MacMullen" <simon at rabbitmq.com>
Cc: "Discussions about RabbitMQ" <rabbitmq-discuss at lists.rabbitmq.com>
Subject: Re: [rabbitmq-discuss] redelivery after ACK
Surely if I have a 1-second delay after I send the ACK, it will have arrived at the server. What would stop it?
All the same, I think I'll fire up Wireshark and see what's happening.
-larry
-----Original Message-----
From: "Simon MacMullen" <simon at rabbitmq.com>
Sent: Wednesday, November 7, 2012 4:50am
To: "Discussions about RabbitMQ" <rabbitmq-discuss at lists.rabbitmq.com>
Cc: larry.edelstein at therealreal.com
Subject: Re: [rabbitmq-discuss] redelivery after ACK
Hmm.
Acks only matter to the server if it receives them. I wonder if you are
killing the script after it has sent acks, but before the server has
received them. That's consistent with what you're seeing re some acks
getting through when you ack a lot - those are the ones that made it all
the way to the server before the client was killed.
You may also be running into the Nagle algorithm. Not sure how you would
disable that for the Ruby gem. Is the author here?
Cheers, Simon
On 07/11/12 03:48, larry.edelstein at therealreal.com wrote:
> Hi folks - I'm new to RabbitMQ. I've got a problem and need some help.
>
> I've posted the question on Stack Overflow at
> http://stackoverflow.com/questions/13262738/redelivery-after-ack, so if
> you want to answer it there, please do! I'll do my best to repost, here,
> any answers I get there, so that rabbitmq-discuss list denizens can also
> see and discuss.
>
> So feel free to go to Stack Overflow, or read it here.
>
>
> Larry Edelstein
>
> Now Answers, Inc.
>
> m (415) 713-9148
>
> ribs at acm.org
>
>
> +++
>
> Why are my RabbitMQ messages being redelivered to my consumer after they
> have been ACKd? I'm new to RabbitMQ; I must be misusing it, or there's
> something wrong perhaps with the Ruby amqp gem.
>
>
> I have a ruby script that subscribes to a queue and acks each message.
> If I let it make it all the way through the messages, the messages
> really do disappear from the queue; they're not redelivered. But if I
> interrupt my script before they're all ACKd, and then start the script
> again, delivery starts anew from the first message.
>
>
> The behavior I'm seeing in code is reflected accurately by the RabbitMQ
> web management interface; the queue has messages, and despite the ACKs,
> they don't disappear.
>
>
> Clue: I put about 5000 messages in the queue. If I let the consumer ACK
> a significant amount, a few messages do actually appear to be removed
> from the queue (contrary to what I said above). I haven't been able to
> nail this phenomenon down.
>
>
> I'm using ruby 1.9.3, RabbitMQ 2.8.7, and the amqp ruby gem 0.9.8. It
> happens with producer and consumer on Ubuntu 12.0.4, or on Mac OS 10.7.4.
>
>
> What the heck??
>
>
> Here's the code for the consumer:
>
>
> # encoding: utf-8
>
> require "rubygems"
>
> require 'amqp'
>
> require 'aws-sdk'
>
> queue_name = "some.queue"
>
> begin
>
> AMQP.start("amqp://localhost:5672") do | connection |
>
> channel = AMQP::Channel.new(connection)
>
> queue = channel.queue(queue_name, :durable => true)
>
> queue.subscribe(:ack => true) do | metadata, payload |
>
> metadata.ack
>
> end
>
> end
>
> end
>
>
> and here's the producer:
>
>
> # encoding: utf-8
>
> require "rubygems"
>
> require 'amqp'
>
> require 'aws-sdk'
>
> msg = ARGV[0]
>
> queue_name = "some.queue"
>
> begin
>
> AMQP.start("amqp://localhost:5672") do | connection |
>
> channel = AMQP::Channel.new(connection)
>
> queue = channel.queue(queue_name, :durable => true)
>
> (1..5000).each do | x |
>
> channel.default_exchange.publish x, :routing_key => queue_name,
> :persistent => true
>
> end
>
> end
>
> end
>
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
--
Simon MacMullen
RabbitMQ, VMware
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121108/19c063eb/attachment.htm>
More information about the rabbitmq-discuss
mailing list