Sha256: 661969b292873d31e5c0f3f51034c5b4dce08de9a1d975529f9a1eece1bc2b80

Contents?: true

Size: 800 Bytes

Versions: 57

Compression:

Stored size: 800 Bytes

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

ch = conn.create_channel
x  = ch.topic("bunny.examples.recovery.topic", :durable => false)
q  = ch.queue("bunny.examples.recovery.client_named_queue1", :durable => false)

q.bind(x, :routing_key => "abc").bind(x, :routing_key => "def")

q.subscribe do |delivery_info, metadata, payload|
  puts "Consumed #{payload}"
end

loop do
  sleep 2
  data = rand.to_s
  rk   = ["abc", "def"].sample

  begin
    x.publish(data, :routing_key => rk)
    puts "Published #{data}, routing key: #{rk}"
  # happens when a message is published before the connection
  # is recovered
  rescue Exception => e
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
bunny-2.11.0.pre1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.10.0 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.9.2 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.9.1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.7 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.7.4 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.8.1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.9.0 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.7.3 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.8.0 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.7.2 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.7.1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.7.0 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.6 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.5 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.4 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.3 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.2 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-2.6.0 examples/connection/automatic_recovery_with_client_named_queues.rb