Sha256: c06bbf150ee97afe24b253924f47860eec90db81fcddc0052b2e3be66043502f

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

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

unless ENV["CI"]
  describe "x-consistent-hash exchanges" 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, 30).to_a.map(&:to_s) }

    let(:n) { 20 }
    let(:m) { 10_000 }

    it "can be used" 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 => "15")
      q2 = ch.queue("", :exclusive => true).bind(x, :routing_key => "15")

      sleep 1.0

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

      sleep 4.0
      q1.message_count.should be > 1000
      q2.message_count.should be > 1000

      ch.close
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bunny-0.9.0.pre10 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0.pre9 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb
bunny-0.9.0.pre8 spec/higher_level_api/integration/consistent_hash_exchange_spec.rb