Sha256: 6e33abb81d6a6a9ba1138b48d44e90bbebfc56700be55293592d8893330a520e

Contents?: true

Size: 1.29 KB

Versions: 31

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"
require "set"

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

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

  context "with explicit acknowledgements mode" do
    class ExampleConsumer < Bunny::Consumer
      def cancelled?
        @cancelled
      end

      def handle_cancellation(_)
        @cancelled = true
      end

      def call(delivery_info, metadata, payload)
         # no-op
      end
    end

    # demonstrates that manual acknowledgement mode is actually
    # used. MK.
    it "requeues messages on channel closure" do
      ch1  = connection.create_channel
      ch2  = connection.create_channel
      q1   = ch1.queue("bunny.tests.consumer_object1", :exclusive => true)
      q2   = ch2.queue("bunny.tests.consumer_object1", :exclusive => true)
      ec   = ExampleConsumer.new(ch1, q1, "", false)
      x    = ch2.default_exchange

      t = Thread.new do
        50.times do
          x.publish("hello", :routing_key => q2.name)
        end
      end
      t.abort_on_exception = true

      q1.subscribe_with(ec, :ack => true)
      sleep 2
      ch1.close

      q2.message_count.should == 50
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
bunny-1.4.1 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.4.0 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.3.1 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.3.0 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.2.2 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.2.1 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.2.0 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.9 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.8 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.7 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.6 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.5 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.4 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.3 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.2 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.1 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.0 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.1.0.rc1 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.0.7 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
bunny-1.0.6 spec/higher_level_api/integration/basic_consume_with_objects_spec.rb