Skip to content

Instantly share code, notes, and snippets.

@groveriffic
Created April 22, 2014 21:59
Show Gist options
  • Save groveriffic/11195922 to your computer and use it in GitHub Desktop.
Save groveriffic/11195922 to your computer and use it in GitHub Desktop.
Basically 'cat' over AMQP to demonstrate exchanges and routing keys
require 'rubygems'
require 'bundler'
Bundler.require(:default)
Bunny.run(ENV['AMQP_URL']) do |conn|
routing_key = 'test.demonstration'
conn.with_channel do |ch|
queue = ch.queue('composinator.test.demonstration')
exchange = ch.direct('composinator')
queue.bind(exchange, routing_key: routing_key)
queue.subscribe(block: true) do |delivery_info, properties, payload|
puts payload
end
end
end
require 'rubygems'
require 'bundler'
Bundler.require(:default)
Bunny.run(ENV['AMQP_URL']) do |conn|
routing_key = 'test.demonstration'
conn.with_channel do |ch|
exchange = ch.direct('composinator')
STDIN.each_line do |message|
exchange.publish(message, routing_key: routing_key)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment