Sha256: 974c0cf5b90ae261082d0cdf37ade6da490af50a1f57ae9c03c6c0b1699f459d

Contents?: true

Size: 1.26 KB

Versions: 18

Compression:

Stored size: 1.26 KB

Contents

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

unless ENV["CI"]
  describe "x-consistent-hash exchange" do
    let(:connection) do
      c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
      c.start
      c
    end

    after :all do
      connection.close
    end

    let(:list) { Range.new(0, 6).to_a.map(&:to_s) }

    let(:m) { 1500 }

    it "distributes messages between queues bound with the same routing key" do
      ch   = connection.create_channel
      body = "сообщение"
      # requires the consistent hash exchange plugin,
      # enable it with
      #
      # $ [sudo] rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
      x    = ch.exchange("bunny.stress.concurrent.consumers", :type => "x-consistent-hash", :durable => true)

      qs = []

      q1 = ch.queue("", :exclusive => true).bind(x, :routing_key => "5")
      q2 = ch.queue("", :exclusive => true).bind(x, :routing_key => "5")

      sleep 1.0

      5.times do |i|
        m.times do
          x.publish(body, :routing_key => list.sample)
        end
        puts "Published #{(i + 1) * m} tiny messages..."
      end

      sleep 2.0
      q1.message_count.should be > 100
      q2.message_count.should be > 100

      ch.close
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bunny-0.10.0 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.pre3 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.8 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.pre2 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.7 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.6 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.5 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.4 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.pre1 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.3 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.2 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.1 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0.rc2 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0.rc1 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0.pre13 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0.pre12 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0.pre11 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb