Notification Application Layer
Summary
The application layer is a small set of collaborating services behind interfaces declared in Abstractions.cs: the dispatcher, the resolver, the template engine, the preference evaluator, the retry policy and the channel-sender registry. It contains the orchestration logic; there is no command/query object model.
Dependency graph
Services and abstractions
| Abstraction | Implementation | Lifetime | Role |
|---|---|---|---|
INotificationDispatcher | NotificationDispatcher | scoped | End-to-end orchestration and manual retry |
IEventNotificationResolver | EventNotificationResolver | singleton | Event payload → notification intents |
ITemplateEngine | TemplateEngine | scoped | Template resolution and rendering |
IPreferenceEvaluator | PreferenceEvaluator | scoped | Opt-out preference decision |
RetryPolicy | RetryPolicy | singleton | Backoff schedule |
IChannelSenderRegistry | ChannelSenderRegistry | singleton | Channel → sender resolution |
Records and results
Abstractions.cs also declares the immutable records that flow through the layer: ResolvedRecipient, NotificationIntent, RenderedTemplate, SendContext, DispatchResult and the DispatchOutcome enum.
Request flow
Both entry points — the event consumer and the API test/retry endpoints — call INotificationDispatcher. The dispatcher composes the resolver, preference evaluator, template engine, sender registry and retry policy, persisting messages, attempts and audit rows through the DbContext.
Error handling
Failures are localized: a null/invalid payload yields no intent; a missing template audits TemplateMissing and continues; a channel with no address is suppressed; delivery exceptions are caught per attempt and retried; and an unhandled consumer error requeues the broker message. The dispatcher does not throw to the caller on ordinary per-channel failures.
Verified absence
There is no MediatR, no command/query handler pipeline, no validation pipeline behavior and no application-service base class. Orchestration is direct method calls.
Requires Confirmation
Whether a command/query abstraction is planned requires confirmation; the current design is a direct service model.
Source References
microservices/src/notification-service/Application/Abstractions.csmicroservices/src/notification-service/Application/NotificationDispatcher.csmicroservices/src/notification-service/Application/TemplateEngine.csmicroservices/src/notification-service/Application/PreferenceEvaluator.cs
Related Articles
See Also
Keywords
Application layer, services, abstractions, dependency graph, request flow.
Revision Information
- Status: Draft
- Last reviewed: 2026-07-21
- Next review: 2026-10-21