Sha256: 36c0cb221cb9aed71465cfcbea49c730f31fef16864dac0cb91e30d18199a713

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8

# simple_headers_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

# 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

15 entries across 15 versions & 2 rubygems

Version Path
bunny-0.7.13 examples/simple_headers_08.rb
bunny-0.7.12 examples/simple_headers_08.rb
bunny-0.7.11 examples/simple_headers_08.rb
bunny-0.7.10 examples/simple_headers_08.rb
sparqcode_bunny-0.0.2 examples/simple_headers_08.rb
bunny-0.7.9 examples/simple_headers_08.rb
sparqcode_bunny-0.0.1 examples/simple_headers_08.rb
bunny-0.7.8 examples/simple_headers_08.rb
bunny-0.7.6 examples/simple_headers_08.rb
bunny-0.7.5 examples/simple_headers_08.rb
bunny-0.7.4 examples/simple_headers_08.rb
bunny-0.7.3 examples/simple_headers_08.rb
bunny-0.7.2 examples/simple_headers_08.rb
bunny-0.7.1 examples/simple_headers_08.rb
bunny-0.7 examples/simple_headers_08.rb