Skip to content

Instantly share code, notes, and snippets.

@mediaslave24
Created October 16, 2015 20:18
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 mediaslave24/c3fc881e8c5b5e4d24e2 to your computer and use it in GitHub Desktop.
Save mediaslave24/c3fc881e8c5b5e4d24e2 to your computer and use it in GitHub Desktop.
$:.unshift File.expand_path('~/amqp/lib')
require 'amqp'
Thread.new { EM.run }
sleep 0.01 until EM.reactor_running?
qname = 'some-queue-name'
connection = AMQP.connect
channel = connection.channel
channel
.queue(qname, auto_delete: true)
.tap(&:purge)
.subscribe(ack: false) do |metadata, payload|
raise 'manual exception'
metadata.reject(requeue: true)
end
100.times do |n|
channel.default_exchange.publish(n.to_s, routing_key: qname)
end
EM.error_handler do |ex|
puts "#{ex.class}: #{ex.message}"
if ex.message =~ /method_class/
puts 'ERROR. Bug reproduced'
exit 1
end
end
EM.add_timer(5) { puts 'OK. Bug not reproduced'; exit 0 }
EM.reactor_thread.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment