Skip to content

Instantly share code, notes, and snippets.

@sonots
Created November 26, 2012 14:25
Show Gist options
  • Save sonots/4148485 to your computer and use it in GitHub Desktop.
Save sonots/4148485 to your computer and use it in GitHub Desktop.
Bunny Publisher and AMQP Subscriber
require 'rubygems'
require 'amqp'
ROUTING_KEY = "test1"
AMQP.start(:host => 'localhost') do
MQ.queue(ROUTING_KEY).publish("hello world")
# AMQP.stop { EM.stop }
end
require 'rubygems'
require 'amqp'
ROUTING_KEY = "test1"
AMQP.start(:host => 'localhost' ) do |connection|
channel = AMQP::Channel.new(connection)
q = MQ.queue(ROUTING_KEY)
q.subscribe do |msg|
puts msg
end
end
require 'rubygems'
require 'bunny'
ROUTING_KEY = "test1"
@channel = Bunny.new(:host => 'localhost')
@channel.start
@exchange = @channel.exchange("", :auto_delete => true)
@exchange.publish "hello world", :key => ROUTING_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment