Created
May 9, 2014 08:53
-
-
Save simonmorley/64f6b784f7c26ee1d1a6 to your computer and use it in GitHub Desktop.
Small Rabbit Consumer Test
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
#!/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