rabbitmq-server/deps/rabbitmq_consistent_hash_ex.../examples/ruby
Michael Klishin 7c47d0925a
Revert "Correct a double quote introduced in #4603"
This reverts commit 6a44e0e2ef.

That wiped a lot of files unintentionally
2022-04-20 16:05:56 +04:00
..
Gemfile Update Bunny dependency 2020-06-11 19:36:42 +03:00
Gemfile.lock Revert "Correct a double quote introduced in #4603" 2022-04-20 16:05:56 +04:00
README.md Explain what the [Ruby] example does 2020-06-11 19:36:55 +03:00
example1.rb Executable examples for Ruby 2018-08-21 18:36:15 +03:00
example2.rb Executable examples for Ruby 2018-08-21 18:36:15 +03:00
example3.rb Executable examples for Ruby 2018-08-21 18:36:15 +03:00

README.md

RabbitMQ Consistent Hash Exchange Examples in Ruby

This directory contains runnable Ruby examples for the RabbitMQ Consistent Hash Exchange plugin. They are the same examples as in the plugin's README file.

Prerequisites

The examples assume a RabbitMQ node with the rabbitmq_consistent_hash_exchange plugin enabled is running on localhost and that default user credentials and virtual host were not deleted.

Dependency Installation

bundle install

Workload Details

This example uses four queues: q1 through q4. The first two of them are bound to a consistent hashing exchange with a weight of 1, while the last two of them use a weight of 2. This means that q3 and q4 will get roughly twice as many published messages routed to them compared to either q1 or q2.

Running the Example

# hashing on the routing key
bundle exec ruby ./example1.rb

# hashing on a custom header
bundle exec ruby ./example2.rb

# hashing on a message property
bundle exec ruby ./example3.rb

Inspecting Queue States

To list bindings to the exchange and their weights, use

rabbitmqctl list_bindings | grep chx

To list queues and the number of ready messages in them:

rabbitmqctl list_queues name messages_ready