Niclas Rothman
Niclas Rothman

Reputation: 31

Single consumer of events

all new to Masstransit and are currently evaluating it for a larger project and wondering if anyone could help get a better understanding of the following challenges:

"Single consumer of events in a loadbalanced environment"
In production our services will be runinng multiple instances for scalability and failvover and be part of a larger ecosystem of microservices. The overall architecture is based on Microsofts eshoponcontainers reference implementation where different microservices are communicating with each other via "integrationevents". When publishing a IntegrationEvent to other services which I assume should be done as described in Masstransit Producers / Publish , https://masstransit-project.com/usage/producers.html#publish, how can I assure that only ONE instance in a specific microservice are processing the event but of course that the event reaches ALL microsystem that depends on the event? When we have done similar solutions based on Azure Functions this requirement has been solved by using the "Singelton" attribute (https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute).

Azure Service Bus
Reading the documentation my impression is that Masstransit is very RabbitMQ centric. Since we will be on the Azure Service bus when moving to production is there any limitations or features not available on that "transport"?

Regards Niclas

Upvotes: 1

Views: 483

Answers (1)

Alexey Zimarev
Alexey Zimarev

Reputation: 19610

For the first question, it's a normal publish-subscribe with competing consumers. It works like this out of the box, there's nothing that needs to be done to achieve this.

When running multiple instances of the same service

  • Use the same queue name for each instance
  • Messages from the queue will be load balanced across all instances (the competing consumer pattern)

It's from the RMQ Guidances, but it's like this for all transports.

Concerning the Azure Service Bus transport, it works as expected and has a lot of production users. It's properly documented as well.

I'd say for both of your questions the answer is "it just works".

Upvotes: 1

Related Questions