-
Notifications
You must be signed in to change notification settings - Fork 748
Cluster Support
EasyNetQ supports RabbitMQ clusters without the need to deploy a load balancer and relies on an implementation of RabbitMQ.Client.
Simply list the nodes of the cluster in the connection string ...
For EasyNetQ v8.x
var serviceCollection = new ServiceCollection();
serviceCollection.AddEasyNetQ("host=ubuntu:5672,ubuntu:5673");
using var provider = serviceCollection.BuildServiceProvider();
var bus = provider.GetRequiredService<IBus>();
For EasyNetQ v7.x
var bus = RabbitHutch.CreateBus("host=ubuntu:5672,ubuntu:5673");
In this example, we have a cluster set up on a single machine, ubuntu, with node 1 on port 5672 and node 2 on port 5673. After connecting to a RabbitMQ broker using AddEasyNetQ in v8.x or CreateBus in v7.x, and a first request(for instance, Publish) are executed, EasyNetQ will attempt to connect to the random host listed (for example, ubuntu:5672). If it fails to connect it will attempt to connect to the unused random host listed (ubuntu:5673). If neither node is available it will sit in a re-try loop attempting to connect to both servers every five seconds by default.
If the node that EasyNetQ is connected to fails, EasyNetQ will attempt to connect to the next listed node. Once connected, it will re-declare all the exchanges and queues and re-start all the consumers.
If a consumer is consuming a queue which is not mirrored (i.e. it exists only on one of the cluster nodes) then it is possible to arrive at a situation where subscribers are not automatically recreated if a broker node goes down & comes back up. For this reason, it is recommended to use mirrored queues when running a RabbitMQ cluster.
For more detail on a specific failure scenario, see https://github.com/EasyNetQ/EasyNetQ/issues/1135
An alternative to the EasyNetQ cluster support is to use a dedicated front-side proxy. See the end of the RabbitMQ clustering guide for details: http://www.rabbitmq.com/clustering.html
- Quick Start
- Introduction
- A Note on Versioning
- Installing EasyNetQ
- EasyNetQ v8 Migration Guide
- Connecting to RabbitMQ
- Connecting with SSL
- Logging
- Logging v8.x
- Publish
- Subscribe
- Request Response
- Send Receive
- Topic Based Routing
- Controlling Queue names
- Polymorphic Publish and Subscribe
- Versioning Messages
- Publisher Confirms
- Scheduling Events with Future Publish
- Support for Delayed Messages Plugin
- Auto Subscriber
- Auto Subscriber v8.x
- Error Conditions
- Re Submitting Error Messages With EasyNetQ.Hosepipe
- The Advanced API
- Cluster Support
- Wiring up EasyNetQ with TopShelf and Windsor
- Replacing EasyNetQ Components
- Using Alternative DI Containers
- Enable Legacy Conventions