Created
November 26, 2012 14:25
-
-
Save sonots/4148485 to your computer and use it in GitHub Desktop.
Bunny Publisher and AMQP Subscriber
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
| require 'rubygems' | |
| require 'amqp' | |
| ROUTING_KEY = "test1" | |
| AMQP.start(:host => 'localhost') do | |
| MQ.queue(ROUTING_KEY).publish("hello world") | |
| # AMQP.stop { EM.stop } | |
| end |
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
| 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 |
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
| 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