[rabbitmq-discuss] redelivery after ACK

larry.edelstein at therealreal.com larry.edelstein at therealreal.com
Wed Nov 7 03:48:47 GMT 2012


 
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


 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121106/dae75c3c/attachment.htm>


More information about the rabbitmq-discuss mailing list