Sha256: 68a83cff9fd9f2b940702c54a2343b44dce44e3ddcf089fc56646f376efe5c64

Contents?: true

Size: 1005 Bytes

Versions: 10

Compression:

Stored size: 1005 Bytes

Contents

# simple_fanout_08.rb

# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
# and that it is running on 'localhost'.

# If this is not the case, please change the 'Bunny.new' call below to include
# the relevant arguments e.g. b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')

$:.unshift File.dirname(__FILE__) + '/../lib'

require 'bunny'

b = Bunny.new(:logging => true)

# start a communication session with the amqp server
b.start

# declare queues
q1 = b.queue('test_fan1')
q2 = b.queue('test_fan2')

# create a fanout exchange
exch = b.exchange('test_fan', :type => :fanout)

# bind the queues to the exchange
q1.bind(exch)
q2.bind(exch)

# publish a message to the exchange
exch.publish('This message will be fanned out')

# get message from the queues
msg = q1.pop[:payload]
puts 'This is the message from q1: ' + msg + "\n\n"
msg = q2.pop[:payload]
puts 'This is the message from q2: ' + msg + "\n\n"

# close the client connection
b.stop

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
sidekick-client-0.2.5 lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb
bunny-0.6.3.rc2 examples/simple_fanout_08.rb
bunny-0.6.3.rc1 examples/simple_fanout_08.rb
sidekick-client-0.2.4 lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb
sidekick-client-0.2.3 lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb
sidekick-client-0.2.2 lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb
sidekick-client-0.2.1 lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb
sidekick-client-0.2.0 lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb
sidekick-client-0.1.0 lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb
bunny-0.6.0 examples/simple_fanout_08.rb