RabbitMQ consistent hashing exchange - queue position on hash ring

21 views
Skip to first unread message

Mani Amoozadeh

unread,
Nov 18, 2024, 3:04:09 PM11/18/24
to Pika

When using consistent hashing exchange in rabbitmq, I came across two conflicting sentences on how the position of a queue is determined on the hash ring.

When binding a queue to the consistent hashing exchange, the routing_key serves as a parameter to influence how the queue gets mapped to the ring. Consider the following code snippet in python.

channel.exchange_declare(exchange='samplehashing', exchange_type='x-consistent-hash')

channel.queue_declare(queue='letterbox1')

channel.queue_bind('letterbox1', 'samplehashing', routing_key='1')

def callback_1(ch, method, properties, body):
print(f'queue 1 received new message: {body}')

channel.basic_consume(queue='letterbox1', auto_ack=True, on_message_callback=callback_1)

I also read somewhere that:

In a consistent hashing exchange, each queue is assigned positions on the hash ring. This is typically done by hashing the queue's name or ID to determine where it sits on the ring.

Which approach is correct?

Luke Bakken

unread,
Nov 18, 2024, 4:28:06 PM11/18/24
to Pika
Hi Mani,

This question is better asked here:


Or here...


Rather than saying "I read somewhere..." you should provide links to all of the  documentation you have read to accomplish your goal.

Reply all
Reply to author
Forward
0 new messages