ServiceBricks.Notification.Microservice
1.4.0
dotnet add package ServiceBricks.Notification.Microservice --version 1.4.0
NuGet\Install-Package ServiceBricks.Notification.Microservice -Version 1.4.0
<PackageReference Include="ServiceBricks.Notification.Microservice" Version="1.4.0" />
<PackageVersion Include="ServiceBricks.Notification.Microservice" Version="1.4.0" />
<PackageReference Include="ServiceBricks.Notification.Microservice" />
paket add ServiceBricks.Notification.Microservice --version 1.4.0
#r "nuget: ServiceBricks.Notification.Microservice, 1.4.0"
#:package ServiceBricks.Notification.Microservice@1.4.0
#addin nuget:?package=ServiceBricks.Notification.Microservice&version=1.4.0
#tool nuget:?package=ServiceBricks.Notification.Microservice&version=1.4.0

ServiceBricks Notification Microservice
Overview
This repository contains the notification microservice built using the ServiceBricks foundation. The notification microservice is responsible for sending emails and SMS messages from the system. It provides a background task to process notify messages, along with retry, should external providers not be available when being sent. It subscribes to service bus messages for email and sms broadcasts, so that the security microservice and others have a default mechanism to send notifications from the system.
Supported Providers
By default, dependency injection is registered with a dummy email and sms provider that does not send any message but simply logs them using an ILogger<> inteface. You must explicitly add a line of code and configurations to register the providers below. You can quickly build your own providers by including the ServiceBricks.Notification.Model NuGet package and implementing the IEmailProvider and ISmsProvider interfaces.
- SendGrid - Nuget Package - ServiceBricks.Notification.SendGrid
Add ServiceBricks:Notification:SendGrid:ApiKey to your appsettings.config
using ServiceBricks.Notification.SendGrid;
services.AddServiceBricksNotificationSendGrid();
- SMTP - Included in ServiceBricks.Notification
See config below
services.AddScoped<IEmailProvider, SmtpEmailProvider>();
SMS
Coming soon! Or build your own as needed.
Data Transfer Objects
NotifyMessageDto - Admin Policy
Used to store a notification message. It additionally contains properties to support the IDpWorkProcess and WorkService for processing the table like a work queue.
public class NotifyMessageDto : DataTransferObject, IDpWorkProcess
{
public string SenderType { get; set; }
public virtual bool IsHtml { get; set; }
public virtual string Priority { get; set; }
public virtual string Subject { get; set; }
public virtual string BccAddress { get; set; }
public virtual string CcAddress { get; set; }
public virtual string ToAddress { get; set; }
public virtual string FromAddress { get; set; }
public virtual string Body { get; set; }
public virtual string BodyHtml { get; set; }
// IDpWorkProcess related
public bool IsError { get; set; }
public bool IsComplete { get; set; }
public int RetryCount { get; set; }
public DateTimeOffset FutureProcessDate { get; set; }
public DateTimeOffset CreateDate { get; set; }
public DateTimeOffset UpdateDate { get; set; }
public DateTimeOffset ProcessDate { get; set; }
public string ProcessResponse { get; set; }
public bool IsProcessing { get; set; }
}
Business Events and Processes
SendNotificationProcess
This process is used to send a notify message. The SendNotificationProcessRule class implements the functionality to send an email or sms sendertype. You can register new rules to handle new sender types or unregister the existing rule and build your own.
Background Tasks and Timers
SendNotificationTimer class
A background timer can be enabled, with an initial delay and interval, that executes the SendNotificationTask.
SendNotificationTask class
This background task invokes the NotifyMessageWorkService
Service Bus
CreateApplicationEmailBroadcast
This microservice subscribes to the CreateApplicationEmailBroadcast message. It is associated to the CreateApplicationEmailRule Business Rule. When receiving the message from service bus, it will attempt to send the notification first, then store the process disposition before creating the message in storage. This reduces the reliance on the timer for sending messages and sends messages immediately when received.
public class CreateApplicationEmailBroadcast : DomainBroadcast<ApplicationEmailDto>
{
public CreateApplicationEmailBroadcast(ApplicationEmailDto obj)
{
DomainObject = obj;
}
}
CreateApplicationSmsBroadcast
This microservice subscribes to the CreateApplicationSmsBroadcast message. It is associated to the CreateApplicationSmsRule Business Rule. When receiving the message from service bus, it will attempt to send the notification first, then store the process disposition before creating the message in storage. This reduces the reliance on the timer for sending messages and sends messages immediately when received.
public class CreateApplicationSmsBroadcast : DomainBroadcast<ApplicationSmsDto>
{
public CreateApplicationSmsBroadcast(ApplicationSmsDto obj)
{
DomainObject = obj;
}
}
Additional
Application Settings
{
// ServiceBricks Settings
"ServiceBricks":{
// Notification Microservice Settings
"Notification": {
// Send Notification Process
"Send": {
"TimerEnabled": false,
"TimerIntervalMilliseconds": 7000,
"TimerDueMilliseconds": 1000,
"EmailFromDefault": "support@servicebricks.com",
"SmsFromDefault": "1234567890",
"IsDevelopment": false,
"DevelopmentEmailTo": "developer@servicebricks.com",
"DevelopmentSmsTo": "1234567890"
},
// SMTP provider
"Smtp": {
"EmailServer": "yourserver.com",
"EmailPort": 123,
"EmailEnableSsl": true,
"EmailUsername": "username",
"EmailPassword": "password"
},
// ServiceBricks.Notification.SendGrid NuGet Package
"SendGrid": {
"ApiKey": "SendGridApiKey"
}
}
}
}
About ServiceBricks
ServiceBricks is the cornerstone for building a microservices foundation. Visit https://ServiceBricks.com to learn more.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ServiceBricks.Cache.Model (>= 1.4.0)
- ServiceBricks.Core (>= 1.4.0)
- ServiceBricks.Notification.Model (>= 1.4.0)
-
net6.0
- ServiceBricks.Cache.Model (>= 1.4.0)
- ServiceBricks.Core (>= 1.4.0)
- ServiceBricks.Notification.Model (>= 1.4.0)
-
net7.0
- ServiceBricks.Cache.Model (>= 1.4.0)
- ServiceBricks.Core (>= 1.4.0)
- ServiceBricks.Notification.Model (>= 1.4.0)
-
net8.0
- ServiceBricks.Cache.Model (>= 1.4.0)
- ServiceBricks.Core (>= 1.4.0)
- ServiceBricks.Notification.Model (>= 1.4.0)
-
net9.0
- ServiceBricks.Cache.Model (>= 1.4.0)
- ServiceBricks.Core (>= 1.4.0)
- ServiceBricks.Notification.Model (>= 1.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.