Last active
August 1, 2018 17:25
-
-
Save we4tech/2f273d37005f2e5af512e7692acf56d3 to your computer and use it in GitHub Desktop.
Rabbit Fanout Exchange Example
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 'bunny' | |
require 'irb' | |
STDOUT.sync = true | |
conn = Bunny.new("amqp://guest:guest@localhost:5672") | |
conn.start | |
ch = conn.create_channel | |
$x = ch.fanout('msgs') | |
IRB.start(__FILE__) | |
# $x.publish('1').publis('2') |
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 'bunny' | |
STDOUT.sync = true | |
conn = Bunny.new("amqp://guest:guest@localhost:5672") | |
conn.start | |
ch = conn.create_channel | |
x = ch.fanout('msgs') | |
ch.queue('q1').bind(x).subscribe(block: true) do |info, meta, payload| | |
puts "payload: Q1 > #{payload}" | |
end | |
puts "Done" |
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 'bunny' | |
STDOUT.sync = true | |
conn = Bunny.new("amqp://guest:guest@localhost:5672") | |
conn.start | |
ch = conn.create_channel | |
x = ch.fanout('msgs') | |
ch.queue('q2').bind(x).subscribe(block: true) do |info, meta, payload| | |
puts "payload: Q2 > #{payload}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment