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.3.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.3.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.2.2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.2.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.2.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.9 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.8 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.7 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.6 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.5 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.4 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.3 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.2 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.0 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.0.rc1 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.0.7 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.0.6 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.0.5 examples/guides/exchanges/headers_exchange_routing.rb
bunny-1.1.0.pre2 examples/guides/exchanges/headers_exchange_routing.rb