Sha256: b755c95e8966fc1fdeb2c26a2ee4292c5f00f5aaf7586f6a9aea6afd6fc3f47b

Contents?: true

Size: 1.26 KB

Versions: 55

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 :each 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

55 entries across 55 versions & 1 rubygems

Version Path
bunny-1.0.0 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.rc3 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.rc2 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.8 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.rc1 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.7 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.6 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.pre6 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.5 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.pre5 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.4 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.3 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-1.0.0.pre4 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.2 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.10.1 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb