File: message_acknowledgement_spec.rb

package info (click to toggle)
ruby-amqp 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,508 kB
  • sloc: ruby: 8,272; sh: 11; makefile: 10
file content (39 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# encoding: utf-8

require 'spec_helper'

unless ENV["CI"]
  describe "Message acknowledgements" do

    #
    # Environment
    #

    include EventedSpec::AMQPSpec

    default_timeout 120

    amqp_before do
      @connection = AMQP.connect
      @channel1   = AMQP::Channel.new(@connection)
      @channel2   = AMQP::Channel.new(@connection)
    end


    it "can be issued for delivery tags >= 192" do
      exchange_name = "amqpgem.tests.fanout#{rand}"
      queue         = @channel1.queue("", :auto_delete => true).bind(exchange_name).subscribe(:ack => true) do |metadata, payload|
        puts "x-sequence = #{metadata.headers['x-sequence']}, delivery_tag = #{metadata.delivery_tag}" if ENV["DEBUG"]
        metadata.ack
        if metadata.delivery_tag >= 999
          done(1.0)
        end
      end

      exchange = @channel2.fanout(exchange_name, :durable => false)
      2000.times do |i|
        exchange.publish("", :headers => { 'x-sequence' => i })
      end
    end
  end  
end