Sha256: 88f83f7a8a8eade0cd59d533cd5c5c939fb75b0bde0b6ae7ee04b3877562982e

Contents?: true

Size: 660 Bytes

Versions: 92

Compression:

Stored size: 660 Bytes

Contents

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

require "rubygems"
require "bunny"

puts "=> Demonstrating connection.blocked"
puts

conn = Bunny.new
conn.start

ch   = conn.create_channel
x    = ch.fanout("amq.fanout")

# This example requires high memory watermark to be set
# really low to demonstrate blocking.
#
# rabbitmqctl set_vm_memory_high_watermark 0.00000001
#
# should do it.

conn.on_blocked do |connection_blocked|
  puts "Connection is blocked. Reason: #{connection_blocked.reason}"
end

conn.on_unblocked do |connection_unblocked|
  puts "Connection is unblocked."
end

x.publish("z" * 1024 * 1024 * 16)

sleep 120.0
puts "Disconnecting..."
conn.close

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
bunny-2.7.3 examples/guides/extensions/connection_blocked.rb
bunny-2.8.0 examples/guides/extensions/connection_blocked.rb
bunny-2.7.2 examples/guides/extensions/connection_blocked.rb
bunny-2.7.1 examples/guides/extensions/connection_blocked.rb
bunny-2.7.0 examples/guides/extensions/connection_blocked.rb
bunny-2.6.6 examples/guides/extensions/connection_blocked.rb
bunny-2.6.5 examples/guides/extensions/connection_blocked.rb
bunny-2.6.4 examples/guides/extensions/connection_blocked.rb
bunny-2.6.3 examples/guides/extensions/connection_blocked.rb
bunny-2.6.2 examples/guides/extensions/connection_blocked.rb
bunny-2.6.1 examples/guides/extensions/connection_blocked.rb
bunny-2.6.0 examples/guides/extensions/connection_blocked.rb
bunny-2.5.1 examples/guides/extensions/connection_blocked.rb
bunny-2.5.0 examples/guides/extensions/connection_blocked.rb
bunny-2.4.0 examples/guides/extensions/connection_blocked.rb
bunny-2.3.1 examples/guides/extensions/connection_blocked.rb
bunny-2.3.0 examples/guides/extensions/connection_blocked.rb
bunny-2.2.2 examples/guides/extensions/connection_blocked.rb
bunny-2.2.1 examples/guides/extensions/connection_blocked.rb
bunny-2.2.0 examples/guides/extensions/connection_blocked.rb