meysamhadeli / booking-microservices

Practical microservices, built with .Net 8, DDD, CQRS, Event Sourcing, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
MIT License
907 stars 182 forks source link

An event has multiple consumer then what will be happen ? #42

Closed akbarbd closed 2 years ago

meysamhadeli commented 2 years ago

Here, I use masstransit and RabbitMQ for asynchronous communication. For each event, we can have multiple consumer and for each consumer we create a new queue. So each consumer subscribe to our queue and receive the event.

You can check this mechanism in code below: https://github.com/meysamhadeli/booking-microservices/blob/main/src/BuildingBlocks/MassTransit/Extensions.cs#L46

akbarbd commented 2 years ago

Yes, you are right. But it works when debug the code, without debug it consume first consumer then change PersistMessage messageStatus.

meysamhadeli commented 2 years ago

Yes, you are right. But it works when debug the code, without debug it consume first consumer then change PersistMessage messageStatus.

I added a sample for RegisterNewUser endpoint and after that publish an event user-created and consume this event in multiple consumers (Flight-Services and Passenger-Services) and it's work correctly.

You can check these changes in this PR: #43