KoKo
KoKo

Reputation: 451

MassTransit Multi Bus or One Bus

I read this article for that how to configure additional bus instances in the MassTransit.

My scenario: I have two personal NuGet packages (for example Notification and Audit Log Package) that each separately has Message Contracts and Consumers, then MassTransit with their own bus registered into each of them.

These packages have been used in the MyApi Application, which also own has Message Contracts and Consumers. and MassTransit with another bus registered into MyApi application.

Now I am unsure about using multibus or one bus. If I use one bus for all of them, then I guess I must be pass the assembly of the packages to MassTransit registration for registering their consumers. Is it right?

services.AddMassTransit(x =>
{
    x.AddConsumer<NotificationConsumers>();
    x.AddConsumer<AuditLogConsumers>();
    x.AddConsumer<MyApiAppConsumers>();
    // etc ...
});

Upvotes: 0

Views: 1190

Answers (1)

Alexey Zimarev
Alexey Zimarev

Reputation: 19610

The main use case for MultiBus is when one application connects to two different broker instances, or even uses different transports. For all other cases, you don't really need MultiBus.

It is mentioned right at the start of the article that you referenced:

However, with broader use of cloud-based platforms comes a greater variety of messaging transports, not to mention HTTP as a transfer protocol. As application sophistication increases, connecting to multiple message transports and/or brokers is becoming more common. Therefore, rather than force developers to create their own solutions, MassTransit has the ability to configure additional bus instances within specific dependency injection containers.

Upvotes: 2

Related Questions