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-1.7.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.1.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.0.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.0.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.0.0.rc2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-2.0.0.rc1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.7.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.6.3 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.6.2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.6.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.6.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.5.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.6.0.rc2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.6.0.rc1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.6.0.pre1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.5.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.5.0.pre2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.5.0.pre1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.4.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.4.0 examples/guides/exchanges/headers_exchange_routing.rb