Skip to content

Instantly share code, notes, and snippets.

@simonmorley
Created May 9, 2014 08:53
Show Gist options
  • Save simonmorley/64f6b784f7c26ee1d1a6 to your computer and use it in GitHub Desktop.
Save simonmorley/64f6b784f7c26ee1d1a6 to your computer and use it in GitHub Desktop.
Small Rabbit Consumer Test
#!/usr/bin/env ruby
# encoding: utf-8
require "bunny"
conn = Bunny.new vhost: '/boxes', user: 'boxes', pass: 'xxx', host: '127.0.0.1'
conn.start
ch = conn.create_channel
x = ch.topic("boxes", durable: true)
q = ch.queue("", durable: true, auto_delete: false)
q.bind(x, :routing_key => '123456')
puts " [*] Waiting for logs. To exit press CTRL+C"
begin
q.subscribe(:block => true) do |delivery_info, properties, body|
puts " [x] #{delivery_info.routing_key}:#{body}"
end
rescue Interrupt => _
ch.close
conn.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment