Sha256: 6852a7f6823d35465279185910e223a862ae8281a5aae2364ed64c1648158192

Contents?: true

Size: 866 Bytes

Versions: 124

Compression:

Stored size: 866 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

require "rubygems"
require "bunny"

puts "=> Headers exchange routing"
puts

conn = Bunny.new
conn.start

ch   = conn.create_channel
x    = ch.headers("headers")

q1   = ch.queue("", :exclusive => true).bind(x, :arguments => {"os" => "linux", "cores" => 8, "x-match" => "all"})
q2   = ch.queue("", :exclusive => true).bind(x, :arguments => {"os" => "osx",   "cores" => 4, "x-match" => "any"})

q1.subscribe do |delivery_info, properties, content|
  puts "#{q1.name} received #{content}"
end
q2.subscribe do |delivery_info, properties, content|
  puts "#{q2.name} received #{content}"
end

x.publish("8 cores/Linux", :headers => {"os" => "linux", "cores" => 8})
x.publish("8 cores/OS X",  :headers => {"os" => "osx",   "cores" => 8})
x.publish("4 cores/Linux", :headers => {"os" => "linux", "cores" => 4})

sleep 0.5
conn.close

Version data entries

124 entries across 124 versions & 1 rubygems

Version Path
bunny-2.17.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.16.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.15.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.14.4 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.14.3 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.14.2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.14.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.13.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.12.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.12.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.12.0.rc1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.11.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.11.0.pre1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.10.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.9.2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.9.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.6.7 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.7.4 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.8.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.9.0 examples/guides/exchanges/headers_exchange_routing.rb