Sha256: 1da2a19fbef21e114adae7a287034deb746772ac422f7fe2f5124dfed03e1140

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

# simple_headers_09.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(:spec => '09')

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

# declare queues
q = b.queue('header_q1')

# create a headers exchange
header_exch = b.exchange('header_exch', :type => :headers)

# bind the queue to the exchange
q.bind(header_exch, :arguments => {'h1'=>'a','x-match'=>'all'})

# publish messages to the exchange
header_exch.publish('Headers test msg 1', :headers => {'h1'=>'a'})
header_exch.publish('Headers test msg 2', :headers => {'h1'=>'z'})


# get messages from the queue - should only be msg 1 that got through
msg = ""
until msg == :queue_empty do
	msg = q.pop[:payload]
	puts 'This is a message from the header_q1 queue: ' + msg + "\n" unless msg == :queue_empty
end

# 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_headers_09.rb
bunny-0.6.3.rc2 examples/simple_headers_09.rb
bunny-0.6.3.rc1 examples/simple_headers_09.rb
sidekick-client-0.2.4 lib/ext/bunny-0.6.0/examples/simple_headers_09.rb
sidekick-client-0.2.3 lib/ext/bunny-0.6.0/examples/simple_headers_09.rb
sidekick-client-0.2.2 lib/ext/bunny-0.6.0/examples/simple_headers_09.rb
sidekick-client-0.2.1 lib/ext/bunny-0.6.0/examples/simple_headers_09.rb
sidekick-client-0.2.0 lib/ext/bunny-0.6.0/examples/simple_headers_09.rb
sidekick-client-0.1.0 lib/ext/bunny-0.6.0/examples/simple_headers_09.rb
bunny-0.6.0 examples/simple_headers_09.rb