Skip to content

Instantly share code, notes, and snippets.

@michaelklishin
Created December 9, 2011 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelklishin/1451989 to your computer and use it in GitHub Desktop.
Save michaelklishin/1451989 to your computer and use it in GitHub Desktop.
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