Created
December 9, 2011 15:29
-
-
Save michaelklishin/1451989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "An AMQP consumer that DOES NOT catch exceptions" do | |
let(:connection) { HotBunnies.connect } | |
let(:channel) { connection.create_channel } | |
after :each do | |
channel.close | |
connection.close | |
end | |
it "becomes inactive" do | |
mailbox = [] | |
exchange = channel.exchange("hot_bunnies.exchanges.fanout#{Time.now.to_i}#{rand}", :type => :fanout, :auto_delete => true) | |
queue = channel.queue("", :auto_delete => true) | |
queue.bind(exchange) | |
consumer = queue.subscribe(:blocking => false) do |meta, payload| | |
n = meta.properties.headers['X-Number'] | |
if n.odd? | |
raise "A failure" | |
else | |
mailbox << payload | |
end | |
end | |
25.times do |i| | |
exchange.publish("Message ##{i}", :routing_key => "xyz", :properties => { | |
:headers => { | |
'X-Number' => i | |
} | |
}) | |
end | |
sleep(0.5) | |
mc, cc = queue.status | |
mc.should == 0 | |
mailbox.size.should == 1 | |
consumer.shutdown! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment