python 3.x - RabbitMQ consistent hashing exchange - queue position - Stack Overflow

When using consistent hashing exchange in rabbitmq, I came across two conflicting sentences on how the

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745666852a4639172.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信