Sha256: 0779193b9bb00261e74bcedf5a5f4983275dcf46bec62d2b621b410df2682956

Contents?: true

Size: 870 Bytes

Versions: 42

Compression:

Stored size: 870 Bytes

Contents

class BaconSubscriber < ActionSubscriber::Base
  manual_acknowledgement!

  def served
    $messages << "#{payload}::#{$messages.size}"
    if $messages.size > 3
      acknowledge
    elsif $messages.size > 2
      nack
    else
      reject
    end
  end
end

describe "Manual Message Acknowledgment", :integration => true do
  let(:connection) { subscriber.connection }
  let(:draw_routes) do
    ::ActionSubscriber.draw_routes do
      default_routes_for BaconSubscriber
    end
  end
  let(:subscriber) { BaconSubscriber }

  it "retries rejected/nacked messages and stops retrying acknowledged messages" do
    ::ActionSubscriber.start_subscribers!
    ::ActivePublisher.publish("bacon.served", "BACON!", "events")

    verify_expectation_within(2.5) do
      expect($messages).to eq(Set.new(["BACON!::0", "BACON!::1", "BACON!::2", "BACON!::3"]))
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
action_subscriber-5.3.3-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.3 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.2-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.2 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.1-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.1 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.1.pre-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.1.pre spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.0-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.3.0 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.4-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.4 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.3-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.3 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.2-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.2 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.1-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.1 spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.0-java spec/integration/manual_acknowledgement_spec.rb
action_subscriber-5.2.0 spec/integration/manual_acknowledgement_spec.rb