Use domain events to explicitly implement side effects of changes within your domain.
Either domain and integration events are the same stuff: notifying that just happened, but their implementation may be different. Domain events are just messages which pushed to a domain event dispatcher, which could be implemented as an in-memory mediator based on an IoC container or any other method.
The purpose of integration events is to propagate committed transactions and updates to additional subsystems, whether they are other microservices, bounded contexts or even external applications. So, they should occur only if the entity is successfully persisted, otherwise it's as if the entire operation never happened.
Integration events - based on asynchronous communication between multiple microservices(other bounded contexts), or even external systems.
Implementation plan
There are usually three portions involved.
Event Producer
Event Consumer
Event Dispatcher
Event producer is a domain entity. Each entity can generate one or more domain events during a business transaction.
Event dispatcher picks up all domain events generated by each entity and dispatches them to event consumers.
Event consumers are classes that subscribe to domain events in advance.
Document from the MS :https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation
Use domain events to explicitly implement side effects of changes within your domain.
Either domain and integration events are the same stuff: notifying that just happened, but their implementation may be different. Domain events are just messages which pushed to a domain event dispatcher, which could be implemented as an in-memory mediator based on an IoC container or any other method.
The purpose of integration events is to propagate committed transactions and updates to additional subsystems, whether they are other microservices, bounded contexts or even external applications. So, they should occur only if the entity is successfully persisted, otherwise it's as if the entire operation never happened.
Implementation plan
There are usually three portions involved.
Event producer is a domain entity. Each entity can generate one or more domain events during a business transaction.
Event dispatcher picks up all domain events generated by each entity and dispatches them to event consumers.
Event consumers are classes that subscribe to domain events in advance.