Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can RabbitMQ cluster be used as a single endpoint by application?

Tags:

rabbitmq

  • There are three nodes in a RabbitMQ cluster as below.
  • Within RabbitMQ, there are two queues, q1 and q2.
  • The master replica of q1 and q2 are distributed on different nodes. Both queues are mirrored by other nodes.
  • There is a load balancer in front of three nodes.
  • AMQP(node port 5672) and Management HTTP API(node port 15672) are exposed by load balancer.

enter image description here

When application establishes a connection through load balancer, it could reach a random RabbitMQ node behind. And this is invisible to application.

Question:

  1. Is it ok for application to consume both queues in a single AMQP channel over a single connection no matter which RabbitMQ node it reaches?

  2. It is ok for application to call management HTTP API no matter which RabbitMQ node its request hits?

like image 666
Mr.Wang from Next Door Avatar asked Oct 22 '25 14:10

Mr.Wang from Next Door


1 Answers

When RabbitMQ is set up as a cluster and you have your queues mirrored across them, it doesn't matter to which node you are connected. Because the AMQP connection for a queue will be automatically routed to the node containing the master queue and this handled by RabbitMQ internally. So, if a request to publish or consume on queue q1 comes, it will be routed to Node #1.

Answers to your question.

  1. It is not advisable to consume more than one queues in a single AMQP connection. Exception from one consuming process may cause the connection to close which will interrupt the other one.

  2. It is ok for application to call management HTTP API no matter which RabbutMQ node its request hits. Once management plugin in a RabbitMQ cluster is enabled, all the nodes will accept the Management HTTP API requests.

Reference: https://www.rabbitmq.com/clustering.html

like image 79
bumblebee Avatar answered Oct 26 '25 03:10

bumblebee