Sha256: ff30515f0ba8e1554d5a98b684b465f4e0e5007731c696ea6260ebc70c2d05de

Contents?: true

Size: 805 Bytes

Versions: 41

Compression:

Stored size: 805 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(rand.to_s, :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

41 entries across 41 versions & 1 rubygems

Version Path
bunny-1.1.5 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.4 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.3 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.2 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.0 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.0.rc1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.7 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.6 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.5 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.0.pre2 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.1.0.pre1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.4 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.3 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.2 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.1 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.0 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.0.rc3 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-1.0.0.rc2 examples/connection/automatic_recovery_with_client_named_queues.rb
bunny-0.10.8 examples/connection/automatic_recovery_with_client_named_queues.rb