문제

I've got a rabbitmq cluster with two nodes. I'd like to create some queues to be hosted on node1, and other queues hosted on node2.

Even when I set the host in ConnectionParameters to node2, the queue will still end up created on node1.

Programmatically, I'm not sure how to use pika to specify the node I'd like a queue created on. There's no such parameter in queue_declare, and passing in the argument like this doesn't seem to work:

channel.queue_declare(queue="whereami", durable=True, exclusive=False, auto_delete=False, callback=on_queue_declared, arguments= {'node':'rabbit@node1'})

Is there any interface for specifying the hosting node? Is there another way to handle this case?

Thanks!

도움이 되었습니까?

해결책

I couldn't find any arguments to specify on which node in cluster queue will be created, but I have a walk around to this. Assume that you have two nodes in cluster rabbit@node1 and rabbit@node2, you can simply specify:

arguments["x-ha-policy"] = "nodes"
arguments["x-ha-policy-params"] = 'rabbit@node1'

This one will create queue that will residue only on node1.

다른 팁

Clusters are usually defined on different hosts, or with different ports on the same host (see docs for more on this).

One can define both a host and a port number as part of the pika.connection.ConnectionParameters.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top