I have a Python client that uses Pika package (0.9.13) and retrieves data from one node in a RabbitMQ cluster. The cluster is composed of two nodes placed in two different host (url_1 and url_2). How can I make my Python client to subscribe to both nodes?
That is the main structure of my code:
import pika
credentials = pika.PlainCredentials(user, password)
connection = pika.BlockingConnection(pika.ConnectionParameters(host=url_1,
credentials=credentials, ssl=ssl, port=port))
channel = connection.channel()
channel.exchange_declare(exchange=exchange.name,
type=exchange.type, durable=exchange.durable)
result = channel.queue_declare(queue=queue.name, exclusive=queue.exclusive,
durable=queue.durable, auto_delete=queue.autoDelete)
channel.queue_bind(exchange=exchange.name, queue=queue.name,
routing_key=binding_key)
channel.basic_consume(callback,
queue=queue.name,
no_ack=True)
channel.start_consuming()