Sha256: e4839f8a61527963aaffb34bfdfcd3d46b1702d89c721f432cffdada8ce16cbd

Contents?: true

Size: 1.22 KB

Versions: 73

Compression:

Stored size: 1.22 KB

Contents

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

unless ENV["CI"]
  describe "Concurrent publishers sharing a connection" do
    let(:connection) do
      c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :automatically_recover => false, :continuation_timeout => 20.0)
      c.start
      c
    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

73 entries across 73 versions & 1 rubygems

Version Path
bunny-1.7.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.7.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.6.3 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.6.2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.6.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.6.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.5.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.6.0.rc2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.6.0.rc1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.6.0.pre1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.5.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.5.0.pre2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.5.0.pre1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.4.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.4.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.3.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.3.0 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.2.2 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.2.1 spec/stress/concurrent_publishers_stress_spec.rb
bunny-1.2.0 spec/stress/concurrent_publishers_stress_spec.rb