Domanda

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!

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top