Sha256: 249c62ee5b0a00019c43412e58c65bcc13ec112456af7321a38ac4a85c05f444

Contents?: true

Size: 744 Bytes

Versions: 4

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(:ack => true)
puts "#{dlq.message_count} messages dead lettered so far"
puts "Rejecting a message"
ch.nack(delivery_info.delivery_tag, false)
sleep 0.2
puts "#{dlq.message_count} messages dead lettered so far"

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bunny-0.9.0.pre8 examples/guides/extensions/dead_letter_exchange.rb
bunny-0.9.0.pre7 examples/guides/extensions/dead_letter_exchange.rb
bunny-0.9.0.pre6 examples/guides/extensions/dead_letter_exchange.rb
bunny-0.9.0.pre5 examples/guides/extensions/dead_letter_exchange.rb