Sha256: 53a6c0d42aab29834700cd3044c2d9fe4a6ccd1f6aacb70f686adb89daff14f6

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

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

require "bundler"
Bundler.setup

$:.unshift(File.expand_path("../../../lib", __FILE__))

require 'bunny'

conn = Bunny.new(:heartbeat_interval => 8)
conn.start

ch1 = conn.create_channel
x1  = ch1.topic("bunny.examples.recovery.e1", :durable => false)
q1  = ch1.queue("bunny.examples.recovery.q1", :durable => false)

q1.bind(x1, :routing_key => "abc").bind(x1, :routing_key => "def")

ch2 = conn.create_channel
x2  = ch2.topic("bunny.examples.recovery.e2", :durable => false)
q2  = ch2.queue("bunny.examples.recovery.q2", :durable => false)

q2.bind(x2, :routing_key => "abc").bind(x2, :routing_key => "def")

q1.subscribe do |delivery_info, metadata, payload|
  puts "Consumed #{payload} at stage one"
  x2.publish(payload, :routing_key => ["abc", "def", "xyz"].sample)
end

q2.subscribe do |delivery_info, metadata, payload|
  puts "Consumed #{payload} at stage two"
end

loop do
  sleep 3
  rk = ["abc", "def", "ghi", "xyz"].sample
  puts "Publishing with routing key #{rk}"
  x1.publish(rand.to_s, :routing_key => rk)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bunny-0.9.2 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.1 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.rc2 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.rc1 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre13 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre12 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre11 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre10 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre9 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre8 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre7 examples/connection/automatic_recovery_with_multiple_consumers.rb
bunny-0.9.0.pre6 examples/connection/automatic_recovery_with_multiple_consumers.rb