Sha256: 00b59f3920901877f42ba29569ddec9969ea472d827b85a3f892bd18101c8edc

Contents?: true

Size: 1.39 KB

Versions: 20

Compression:

Stored size: 1.39 KB

Contents

require "spec_helper"

describe "A message" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :all do
    connection.close if connection.open?
  end

  it "is considered to be dead-lettered when it is rejected without requeueing" do
    ch   = connection.create_channel
    x    = ch.fanout("amq.fanout")
    dlx  = ch.fanout("bunny.tests.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)
    dlq.message_count.should be_zero
    ch.nack(delivery_info.delivery_tag)

    sleep 0.2
    q.message_count.should be_zero
    dlq.message_count.should == 1

    dlx.delete
  end

  it "is considered to be dead-lettered when it expires" do
    ch   = connection.create_channel
    x    = ch.fanout("amq.fanout")
    dlx  = ch.fanout("bunny.tests.dlx.exchange")
    q    = ch.queue("", :exclusive => true, :arguments => {"x-dead-letter-exchange" => dlx.name, "x-message-ttl" => 100}).bind(x)
    # dead letter queue
    dlq  = ch.queue("", :exclusive => true).bind(dlx)

    x.publish("")
    sleep 0.2

    q.message_count.should be_zero
    dlq.message_count.should == 1

    dlx.delete
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bunny-0.10.0 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-1.0.0.pre3 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.8 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-1.0.0.pre2 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.7 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.6 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.5 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.4 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-1.0.0.pre1 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.3 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.2 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.1 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0.rc2 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0.rc1 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0.pre13 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0.pre12 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0.pre11 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0.pre10 spec/higher_level_api/integration/dead_lettering_spec.rb
bunny-0.9.0.pre9 spec/higher_level_api/integration/dead_lettering_spec.rb