Sha256: 9c74e0ece8a5110d809d6a7b24765f425150f2fd8c6a23ec01b22f72c8a08873

Contents?: true

Size: 1.09 KB

Versions: 30

Compression:

Stored size: 1.09 KB

Contents

# -*- coding: utf-8 -*-
require "spec_helper"

unless ENV["CI"]
  describe "Concurrent publishers sharing a connection" do
    before :all do
      @connection = Bunny.new(username: "bunny_gem", password: "bunny_password",
        vhost: "bunny_testbed", automatically_recover: false)
      @connection.start
    end

    after :all do
      @connection.close
    end

    let(:concurrency) { 24 }
    let(:messages)    { 5_000 }

    it "successfully finish publishing" do
      body = "сообщение"

      chs  = {}
      concurrency.times do |i|
        ch     = @connection.create_channel
        ch.confirm_select
        chs[i] = ch
      end

      ts = []

      concurrency.times do |i|
        t = Thread.new do
          cht = chs[i]
          x   = cht.default_exchange

          messages.times do
            x.publish(body)
          end
          puts "Published #{messages} messages..."
          cht.wait_for_confirms
        end
        t.abort_on_exception = true

        ts << t
      end

      ts.each do |t|
        t.join
      end

      chs.each { |_, ch| ch.close }
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
bunny-2.19.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.18.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.17.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.16.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.15.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.14.4 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.14.3 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.14.2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.14.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.13.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.12.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.12.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.12.0.rc1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.11.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.11.0.pre1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.10.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.9.2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.9.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.6.7 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.7.4 spec/stress/concurrent_publishers_stress_spec.rb