Notifications and Events
Publish domain events with MediatR.
Requests vs Notifications
A request has one handler and returns a value. A notification is a broadcast: it has zero or more handlers and returns nothing. Use notifications to announce that something happened.
// Request: one handler, returns a result
// Notification: many handlers, fire-and-forgetINotification
A domain event is a record implementing INotification. It describes a fact in the past tense.
public record OrderPlacedNotification(int OrderId, int CustomerId)
: INotification;All lessons in this course
- CQRS Concepts
- Commands and Handlers with MediatR
- Pipeline Behaviors
- Notifications and Events