最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论