Skip to main content

Notification Runtime Composition

Summary

The service is a Microsoft.NET.Sdk.Web project targeting net8.0 with nullable and implicit usings enabled. Program.cs builds a WebApplication, registers observability, messaging, options, the DbContext, application services, channel senders and the event consumer, then applies migrations, seeds default templates and maps the endpoints.

Startup sequence

Dependency-injection registrations

Verified registrations in Program.cs:

  • RetryPolicy — singleton.
  • IEventNotificationResolverEventNotificationResolver — singleton.
  • ITemplateEngineTemplateEngine — scoped.
  • IPreferenceEvaluatorPreferenceEvaluator — scoped.
  • INotificationDispatcherNotificationDispatcher — scoped.
  • IChannelSenderInAppSender, SmsSender, WhatsAppSender — singletons; the email sender is chosen at startup by the Notification:Email:Provider value (smtpSmtpEmailSender, noopNoOpEmailSender, otherwise ConsoleEmailSender).
  • IChannelSenderRegistryChannelSenderRegistry — singleton.
  • NotificationEventConsumer — hosted BackgroundService.
  • NotificationDbContext — Npgsql, using the NotificationDb connection string.
  • Swagger generation and ASP.NET Core health checks.

Configuration binding

NotificationOptions binds the Notification section: RabbitMQ queue/dead-letter names and prefetch, Retry (max attempts, base delay, backoff factor), StaleAfterHours, an optional per-event EventChannels override map, Email/Sms/WhatsApp provider settings and SeedDefaultTemplates. Observability and RabbitMq sections are bound by shared-kernel helpers.

Hosting endpoints

The application maps /health (health checks), a root service-info endpoint via MapHrSuitServiceInfo, Swagger UI, and the notification endpoints via MapNotificationEndpoints. The http launch profile listens on port 5074.

Startup side effects

Unless the SKIP_MIGRATIONS environment variable equals true, the service applies EF Core migrations on startup and, when SeedDefaultTemplates is enabled, seeds the built-in global templates idempotently.

Requires Confirmation

Production hosting, container image, replica count and the environment values for provider selection and broker connectivity require confirmation.

Source References

  • microservices/src/notification-service/Program.cs
  • microservices/src/notification-service/Application/NotificationOptions.cs
  • microservices/src/notification-service/Properties/launchSettings.json
  • microservices/src/notification-service/notification-service.csproj

See Also

Keywords

Runtime composition, dependency injection, hosted service, startup, configuration.

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-21
  • Next review: 2026-10-21