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-0.10.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.0.0.pre3 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.8 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.0.0.pre2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.7 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.6 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.5 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.4 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.0.0.pre1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.3 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0.rc2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0.rc1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0.pre13 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0.pre12 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0.pre11 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0.pre10 examples/guides/exchanges/headers_exchange_routing.rb
bunny-0.9.0.pre9 examples/guides/exchanges/headers_exchange_routing.rb