Sha256: 56ee6262980dd9e58d7b003f39e782b6a7f15bb677f8f063ce8011f13d250e81

Contents?: true

Size: 975 Bytes

Versions: 18

Compression:

Stored size: 975 Bytes

Contents

# fanout.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
puts 'This is the message from q1: ' + msg + "\n\n"
msg = q2.pop
puts 'This is the message from q2: ' + msg + "\n\n"

# close the client connection
b.stop

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
celldee-bunny-0.2.0 examples/simple_fanout.rb
celldee-bunny-0.3.1 examples/simple_fanout.rb
celldee-bunny-0.4.0 examples/simple_fanout.rb
celldee-bunny-0.4.1 examples/simple_fanout.rb
celldee-bunny-0.4.2 examples/simple_fanout.rb
celldee-bunny-0.4.3 examples/simple_fanout.rb
celldee-bunny-0.4.4 examples/simple_fanout.rb
celldee-bunny-0.5.0 examples/simple_fanout_08.rb
celldee-bunny-0.5.1 examples/simple_fanout_08.rb
fotonauts-bunny-0.4.0 examples/simple_fanout.rb
bunny-0.5.1 examples/simple_fanout_08.rb
bunny-0.4.4 examples/simple_fanout.rb
bunny-0.4.0 examples/simple_fanout.rb
bunny-0.2.0 examples/simple_fanout.rb
bunny-0.4.1 examples/simple_fanout.rb
bunny-0.3.1 examples/simple_fanout.rb
bunny-0.4.3 examples/simple_fanout.rb
bunny-0.4.2 examples/simple_fanout.rb