chris R
chris R

Reputation: 11

Is it possible for multiple consumers mass transit and azure service bus

I have a scenario to update two related tables on a button click event.

I am using mass transit with azure service bus

so the requirement is to publish messages and have multiple consumer service instances receive them.

I have written consumer to update one table. Is it possible for multiple consumers to listen to one end point and update respective table. Can i get some guidance on the configuration or a working sample?

Sample answer to start with the implementation

Upvotes: 0

Views: 645

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33278

A single consumer (same namespace + type name) can be used across multiple services by specifying an InstanceId when registering the consumer.

x.AddConsumer<SubmitOrderConsumer, SubmitOrderConsumerDefinition>()
    .Endpoint(x => x.InstanceId = "something-unique-per-instance");

MassTransit will then append that value to the default endpoint name.

Upvotes: 1

Related Questions