ruby-amqp/bunny — Issue #25: Unsubscribing from a queue that has a message on it raises an exception.
Author: MikeEmery
Created: 2011-10-09 08:16:22+00:00
State: open

This is the same code I used:

require 'rubygems'
require 'bunny'

b = Bunny.new(:host => '127.0.0.1', :spec => '09', :logging => true)
b.start

exchange = b.exchange('')

q = b.queue(nil, :exclusive => false)

exchange.publish('abc', :key => q.name)
exchange.publish('abc', :key => q.name)

puts '.'

q.subscribe( :timeout => 5, :message_max => 1 ) do |msg|
puts msg[:payload]
end

puts '.'

The exception I receive:

/Users/mike/.rvm/gems/ruby-1.8.7-p334/gems/bunny-0.7.6/lib/bunny/client09.rb:55:in `check_response': Error unsubscribing from queue amq.gen-5883aQtSztoCgUHv1guX9g== (Bunny::ProtocolError)
from /Users/mike/.rvm/gems/ruby-1.8.7-p334/gems/bunny-0.7.6/lib/bunny/queue09.rb:308:in `unsubscribe'
from /Users/mike/.rvm/gems/ruby-1.8.7-p334/gems/bunny-0.7.6/lib/qrack/subscription.rb:86:in `consume'
from /Users/mike/.rvm/gems/ruby-1.8.7-p334/gems/bunny-0.7.6/lib/qrack/subscription.rb:56:in `loop'
from /Users/mike/.rvm/gems/ruby-1.8.7-p334/gems/bunny-0.7.6/lib/qrack/subscription.rb:56:in `consume'
from /Users/mike/.rvm/gems/ruby-1.8.7-p334/gems/bunny-0.7.6/lib/bunny/queue09.rb:248:in `subscribe'
from test.rb:17
And here's the raw log:

I, [2011-10-09 01:12:14#15961] INFO -- received: #"2.6.1", :information=>"Licensed under the MPL. See http://www.rabbitmq.com/", :copyright=>"Copyright (C) 2007-2011 VMware, Inc.", :capabilities=>{:consumer_cancel_notify=>1, :"basic.nack"=>1, :publisher_confirms=>1, :exchange_exchange_bindings=>1}, :platform=>"Erlang/OTP", :product=>"RabbitMQ"}, @version_minor=9, @locales="en_US", @version_major=0, @mechanisms="PLAIN AMQPLAIN">, @channel=0>
I, [2011-10-09 01:12:14#15961] INFO -- send: #"0.7.6", :information=>"http://github.com/ruby-amqp/bunny", :platform=>"Ruby", :product=>"Bunny"}, @locale="en_US", @response="\000guest\000guest">, @channel=0>
I, [2011-10-09 01:12:14#15961] INFO -- received: #, @channel=0>
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=0>
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=0>
I, [2011-10-09 01:12:14#15961] INFO -- received: #, @channel=0>
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- received: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- received: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- send: #"application/octet-stream", :delivery_mode=>1, :priority=>0}>, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- send: #
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- send: #"application/octet-stream", :delivery_mode=>1, :priority=>0}>, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- send: #
.
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- received: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- received: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- received: #"application/octet-stream", :delivery_mode=>1, :priority=>0}>, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- received: #
abc
I, [2011-10-09 01:12:14#15961] INFO -- send: #, @channel=1>
I, [2011-10-09 01:12:14#15961] INFO -- received: #, @channel=1>