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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ServiceBricks.Notification.Microservice" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ServiceBricks.Notification.Microservice" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="ServiceBricks.Notification.Microservice" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ServiceBricks.Notification.Microservice --version 1.4.0
                    
#r "nuget: ServiceBricks.Notification.Microservice, 1.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ServiceBricks.Notification.Microservice@1.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ServiceBricks.Notification.Microservice&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=ServiceBricks.Notification.Microservice&version=1.4.0
                    
Install as a Cake Tool

ServiceBricks Logo

NuGet version badge License: MIT

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.

Email
  • 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.

View Source

SendNotificationTask class

This background task invokes the NotifyMessageWorkService

View Source

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 0 1/1/2026
1.4.0-e 263 12/18/2025
1.4.0-d 263 12/16/2025
1.4.0-c 205 12/14/2025
1.4.0-a 402 12/8/2025
1.3.0 227 3/18/2025
1.3.0-c 185 3/16/2025
1.3.0-a 159 2/2/2025
1.2.0 139 1/14/2025
1.1.3 168 12/1/2024