Sha256: 6be43b01a41444a342fa0718d726141321d64c707d3c028df23dcc61d0a1e118

Contents?: true

Size: 728 Bytes

Versions: 12

Compression:

Stored size: 728 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_timeout: 8)
conn.start

ch = conn.create_channel
x  = ch.topic("bunny.examples.recovery.topic", :durable => false)
q  = ch.queue("", :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)
  # happens when a message is published before the connection
  # is recovered
  rescue Bunny::ConnectionClosedError => e
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bunny-2.17.0 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.16.1 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.15.0 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.14.4 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.14.3 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.14.2 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.14.1 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.13.0 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.12.1 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.12.0 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.12.0.rc1 examples/connection/automatic_recovery_with_server_named_queues.rb
bunny-2.11.0 examples/connection/automatic_recovery_with_server_named_queues.rb