Notification Commands
Summary
The Notification Service does not implement a formal command object model or CQRS command handlers. Write operations (“commands” in the conceptual sense) are performed inline by the dispatcher and by Minimal API endpoint handlers that mutate entities directly through the DbContext.
Verified write operations
| Operation | Where implemented | Effect (verified) |
|---|---|---|
| Dispatch an event | NotificationDispatcher.DispatchAsync | Upserts recipient, creates messages, records attempts, marks processed, writes audit |
| Retry a message | NotificationDispatcher.RetryMessageAsync and /notifications/{id}/retry | Resets message to Pending and re-runs delivery |
| Mark a notification read | POST /notifications/{id}/read | Sets status Read, ReadOnUtc, writes a Read audit row |
| Create a template version | POST /notification-templates | Inserts the next Version for a (tenant, key, channel) |
| Update a template | PUT /notification-templates/{id} | Applies supplied fields in place |
| Test-render / live-send a template | POST /notification-templates/{id}/test | Renders and optionally persists a message and one delivery attempt |
| Publish/dispatch a test event | POST /notifications/test/dispatch and /test/publish | Drives the pipeline or the broker for verification |
Write model
Each write handler validates minimal inputs, mutates tracked entities and calls SaveChangesAsync. There is no command bus, no handler registration and no command validation pipeline; guards are inline (for example, required templateKey/channel and a known-channel check).
Verified absence
There are no *Command classes, no ICommandHandler, no MediatR requests and no unit-of-work abstraction. SaveChangesAsync on NotificationDbContext is the transaction boundary for each write.
Requires Confirmation
Whether a command abstraction is planned for consistency with other services requires confirmation.
Source References
microservices/src/notification-service/Api/NotificationEndpoints.csmicroservices/src/notification-service/Application/NotificationDispatcher.cs
Related Articles
See Also
Keywords
Commands, write operations, mutations, endpoints, verified absence.
Revision Information
- Status: Draft
- Last reviewed: 2026-07-21
- Next review: 2026-10-21