Sha256: d2a6213df3522bc6586037a17f9fa576592f2de9f4b3843e637af468b67dd1ae

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

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

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

    after :all do
      @connection.close
    end

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

    it "successfully finish publishing" do
      ch = @connection.create_channel

      q    = ch.queue("", :exclusive => true)
      body = "сообщение"

      # let the queue name be sent back by RabbitMQ
      sleep 0.25

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

      ts = []

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

          5.times do |i|
            rate.times do
              x.publish(body, :routing_key => q.name)
            end
            puts "Published #{(i + 1) * rate} messages..."
          end
        end
        t.abort_on_exception = true

        ts << t
      end

      ts.each do |t|
        t.join
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bunny-2.3.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.3.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.2.2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.2.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.2.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.1.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.0.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.0.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.0.0.rc2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-2.0.0.rc1 spec/stress/concurrent_publishers_stress_spec.rb