Created
July 25, 2008 08:25
-
-
Save tmm1/2412 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$:.unshift File.dirname(__FILE__) + '/../lib' | |
require 'mq' | |
EM.run do | |
# open a channel on the AMQP connection | |
channel = MQ.new | |
# declare a queue on the channel | |
queue = MQ::Queue.new(channel, 'queue name') | |
# use the default fanout exchange | |
exchange = MQ::Exchange.new(channel, :fanout, 'all queues') | |
# bind the queue to the exchange | |
queue.bind(exchange) | |
# publish a message to the exchange | |
exchange.publish('hello world') | |
# subscribe to messages from the queue | |
queue.subscribe do |headers, msg| | |
p [:got, headers, msg] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment