Sha256: 3129d42d1c690e47c34eef70a2be30096f23edc15fe849a9ef5ca9f14ca2d780

Contents?: true

Size: 744 Bytes

Versions: 58

Compression:

Stored size: 744 Bytes

Contents

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

require "rubygems"
require "bunny"

puts "=> Demonstrating dead letter exchange"
puts

conn = Bunny.new
conn.start

ch   = conn.create_channel
x    = ch.fanout("amq.fanout")
dlx  = ch.fanout("bunny.examples.dlx.exchange")
q    = ch.queue("", :exclusive => true, :arguments => {"x-dead-letter-exchange" => dlx.name}).bind(x)
# dead letter queue
dlq  = ch.queue("", :exclusive => true).bind(dlx)

x.publish("")
sleep 0.2

delivery_info, _, _ = q.pop(:manual_ack => true)
puts "#{dlq.message_count} messages dead lettered so far"
puts "Rejecting a message"
ch.nack(delivery_info.delivery_tag)
sleep 0.2
puts "#{dlq.message_count} messages dead lettered so far"

dlx.delete
puts "Disconnecting..."
conn.close

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
bunny-2.17.0 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.16.1 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.15.0 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.14.4 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.14.3 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.14.2 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.14.1 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.13.0 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.12.1 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.12.0 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.12.0.rc1 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.11.0 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.11.0.pre1 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.10.0 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.9.2 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.9.1 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.6.7 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.7.4 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.8.1 examples/guides/extensions/dead_letter_exchange.rb
bunny-2.9.0 examples/guides/extensions/dead_letter_exchange.rb