Using RabbitMQ in a cluster

The RabbitMQ Clustering Guide recommends that client applications should not hard-code the hostnames or IP addresses of the machines hosting nodes in a RabbitMQ cluster. An approach such as DNS or load balancing should be used instead. This approach is recommended when using the NServiceBus RabbitMQ transport.

If each client is deployed to a machine which is running at least one RabbitMQ node in the cluster, another approach is to configure the client to only connect to the local node, e.g. using localhost as the hostname. Note that the RabbitMQ nodes must still be clustered, otherwise clients on each machine will have access only to the messages which originated locally.

Connecting to additional nodes

Connecting to multiple nodes within a cluster is only possible by using a load balancer in front of the cluster. The RabbitMQTransport must be configured to connect to the load balancer.

RabbitMQ has a concept of a single master queue and this can result in unnecessary network hops. See load balancing a rabbitmq cluster.

Related Articles

Last modified