examples/routing/headers_routing.rb in amqp-0.8.0.rc13 vs examples/routing/headers_routing.rb in amqp-0.8.0.rc14
- old
+ new
@@ -16,38 +16,40 @@
puts "A channel-level exception: #{channel_close.inspect}"
end
exchange = channel.headers("amq.match", :durable => true)
- channel.queue("", :auto_delete => true).bind(exchange, :arguments => { 'x-match' => 'all', :arch => "x64", :os => 'linux' }).subscribe do |metadata, payload|
- puts "[linux/x64] Got a message: #{payload}"
+ channel.queue("", :auto_delete => true).bind(exchange, :arguments => { 'x-match' => 'all', :arch => "ia64", :os => 'linux' }).subscribe do |metadata, payload|
+ puts "[linux/ia64] Got a message: #{payload}"
end
- channel.queue("", :auto_delete => true).bind(exchange, :arguments => { 'x-match' => 'all', :arch => "x32", :os => 'linux' }).subscribe do |metadata, payload|
- puts "[linux/x32] Got a message: #{payload}"
+ channel.queue("", :auto_delete => true).bind(exchange, :arguments => { 'x-match' => 'all', :arch => "x86", :os => 'linux' }).subscribe do |metadata, payload|
+ puts "[linux/x86] Got a message: #{payload}"
end
- channel.queue("", :auto_delete => true).bind(exchange, :arguments => { 'x-match' => 'any', :os => 'linux', :arch => "__any__" }).subscribe do |metadata, payload|
+ channel.queue("", :auto_delete => true).bind(exchange, :arguments => { :os => 'linux'}).subscribe do |metadata, payload|
puts "[linux] Got a message: #{payload}"
end
channel.queue("", :auto_delete => true).bind(exchange, :arguments => { 'x-match' => 'any', :os => 'macosx', :cores => 8 }).subscribe do |metadata, payload|
puts "[macosx|octocore] Got a message: #{payload}"
end
+ channel.queue("", :auto_delete => true).bind(exchange, :arguments => { :package => { :name => 'riak', :version => '0.14.2' } }).subscribe do |metadata, payload|
+ puts "[riak/0.14.2] Got a message: #{payload}"
+ end
-
EventMachine.add_timer(0.5) do
- exchange.publish "For linux/x64", :headers => { :arch => "x64", :os => 'linux' }
- exchange.publish "For linux/x32", :headers => { :arch => "x32", :os => 'linux' }
- exchange.publish "For linux", :headers => { :os => 'linux' }
- exchange.publish "For OS X", :headers => { :os => 'macosx' }
- exchange.publish "For solaris/x64", :headers => { :os => 'solaris', :arch => 'x64' }
- exchange.publish "For ocotocore", :headers => { :cores => 8 }
+ exchange.publish "For linux/ia64", :headers => { :arch => "ia64", :os => 'linux' }
+ exchange.publish "For linux/x86", :headers => { :arch => "x86", :os => 'linux' }
+ exchange.publish "For linux", :headers => { :os => 'linux' }
+ exchange.publish "For OS X", :headers => { :os => 'macosx' }
+ exchange.publish "For solaris/ia64", :headers => { :os => 'solaris', :arch => 'ia64' }
+ exchange.publish "For ocotocore", :headers => { :cores => 8 }
+
+ exchange.publish "For nodes with Riak 0.14.2", :headers => { :package => { :name => 'riak', :version => '0.14.2' } }
end
show_stopper = Proc.new do
$stdout.puts "Stopping..."
- connection.close {
- EventMachine.stop { exit }
- }
+ connection.close { EventMachine.stop }
end
Signal.trap "INT", show_stopper
EventMachine.add_timer(2, show_stopper)
end