Skip to content

Commit 0ac7e3b

Browse files
Update README.md
1 parent 20e8819 commit 0ac7e3b

1 file changed

Lines changed: 53 additions & 40 deletions

File tree

README.md

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![ServiceBricks Logo](https://github.com/holomodular/ServiceBricks/blob/main/Logo.png)
1+
![ServiceBricks Logo](https://raw.githubusercontent.com/holomodular/ServiceBricks/main/Logo.png)
22

33
[![NuGet version](https://badge.fury.io/nu/ServiceBricks.Notification.Microservice.svg)](https://badge.fury.io/nu/ServiceBricks.Notification.Microservice)
44
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/holomodular-support/e48b40f2064d0b0a359109f864c3aff7/raw/servicebricksnotification-codecoverage.json)
@@ -8,30 +8,37 @@
88

99
## Overview
1010

11-
This repository contains a notification microservice built using the ServiceBricks foundation.
12-
The notification microservice is responsible for send emails and SMS messages from the system.
13-
It provides a background task to process notify messages, along with retry, should external providers not be available.
14-
It also 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.
11+
This repository contains the notification microservice built using the ServiceBricks foundation.
12+
The notification microservice is responsible for sending emails and SMS messages from the system.
13+
It provides a background task to process notify messages, along with retry, should external providers not be available when being sent.
14+
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.
1515

1616
### Supported Providers
1717
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.
18-
You must explicitly add a line of code to register the providers below.
18+
You must explicitly add a line of code and configurations to register the providers below.
19+
You can quickly build your own providers by including the **ServiceBricks.Notification.Model** NuGet package and implementing the IEmailProvider and ISmsProvider interfaces.
1920

2021

2122
#### Email
2223

2324
* SendGrid - Nuget Package - ServiceBricks.Notification.SendGrid
2425

26+
Add ServiceBricks:Notification:SendGrid:ApiKey to your appsettings.config
2527
```csharp
28+
using ServiceBricks.Notification.SendGrid;
2629
services.AddServiceBricksNotificationSendGrid();
2730
```
2831

29-
* Smtp - Included in ServiceBricks.Notification
32+
* SMTP - Included in ServiceBricks.Notification
3033

34+
See config below
3135
```csharp
3236
services.AddScoped<IEmailProvider, SmtpEmailProvider>();
3337
```
3438

39+
#### SMS
40+
41+
Coming soon! Or build your own as needed.
3542

3643
## Data Transfer Objects
3744

@@ -40,9 +47,20 @@ Used to store a notification message. It additionally contains properties to sup
4047

4148
```csharp
4249

43-
public class NotifyMessageDto : DataTransferObject
44-
{
45-
public int SenderTypeKey { get; set; }
50+
public class NotifyMessageDto : DataTransferObject, IDpWorkProcess
51+
{
52+
public string SenderType { get; set; }
53+
public virtual bool IsHtml { get; set; }
54+
public virtual string Priority { get; set; }
55+
public virtual string Subject { get; set; }
56+
public virtual string BccAddress { get; set; }
57+
public virtual string CcAddress { get; set; }
58+
public virtual string ToAddress { get; set; }
59+
public virtual string FromAddress { get; set; }
60+
public virtual string Body { get; set; }
61+
public virtual string BodyHtml { get; set; }
62+
63+
// IDpWorkProcess related
4664
public bool IsError { get; set; }
4765
public bool IsComplete { get; set; }
4866
public int RetryCount { get; set; }
@@ -53,15 +71,6 @@ public class NotifyMessageDto : DataTransferObject
5371
public string ProcessResponse { get; set; }
5472
public bool IsProcessing { get; set; }
5573

56-
public virtual bool IsHtml { get; set; }
57-
public virtual string Priority { get; set; }
58-
public virtual string Subject { get; set; }
59-
public virtual string BccAddress { get; set; }
60-
public virtual string CcAddress { get; set; }
61-
public virtual string ToAddress { get; set; }
62-
public virtual string FromAddress { get; set; }
63-
public virtual string Body { get; set; }
64-
public virtual string BodyHtml { get; set; }
6574
}
6675

6776
```
@@ -70,12 +79,13 @@ public class NotifyMessageDto : DataTransferObject
7079

7180
### SendNotificationProcess
7281
This process is used to send a notify message. The SendNotificationProcessRule class implements the functionality to send an email or sms sendertype.
82+
You can register new rules to handle new sender types or unregister the existing rule and build your own.
7383

7484

7585
## Background Tasks and Timers
7686

7787
### SendNotificationTimer class
78-
This background timer runs every 10 seconds, with an initial delay of 1 second. Executes the SendNotificationTask.
88+
A background timer can be enabled, with an initial delay and interval, that executes the SendNotificationTask.
7989

8090
[View Source](https://github.com/holomodular/ServiceBricks-Notification/blob/main/src/V1/ServiceBricks.Notification/Background/SendNotificationTimer.cs)
8191

@@ -90,7 +100,8 @@ This background task invokes the [NotifyMessageWorkService](https://github.com/h
90100
### CreateApplicationEmailBroadcast
91101
This microservice subscribes to the CreateApplicationEmailBroadcast message.
92102
It is associated to the [CreateApplicationEmailRule](https://github.com/holomodular/ServiceBricks-Notification/blob/main/src/V1/ServiceBricks.Notification/Rule/CreateApplicationEmailRule.cs) Business Rule.
93-
When receiving the message, it will simply create a record in storage and allow the background process to pick it up to process it.
103+
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.
104+
94105
```csharp
95106

96107
public class CreateApplicationEmailBroadcast : DomainBroadcast<ApplicationEmailDto>
@@ -106,7 +117,7 @@ When receiving the message, it will simply create a record in storage and allow
106117
### CreateApplicationSmsBroadcast
107118
This microservice subscribes to the CreateApplicationSmsBroadcast message.
108119
It is associated to the [CreateApplicationSmsRule](https://github.com/holomodular/ServiceBricks-Notification/blob/main/src/V1/ServiceBricks.Notification/Rule/CreateApplicationSmsRule.cs) Business Rule.
109-
When receiving the message, it will simply create a record in storage and allow the background process to pick it up to process it.
120+
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.
110121
```csharp
111122

112123
public class CreateApplicationSmsBroadcast : DomainBroadcast<ApplicationSmsDto>
@@ -132,27 +143,29 @@ When receiving the message, it will simply create a record in storage and allow
132143

133144
// Notification Microservice Settings
134145
"Notification": {
135-
"Options": {
136-
// Default from address for email and sms, if not specified when created
137-
"EmailFromDefault": "support@servicebricks.com",
138-
"SmsFromDefault": "1234567890",
139-
140-
// when in development mode, emails and sms messages will be sent to only these addresses
141-
"IsDevelopment": true,
142-
"DevelopmentEmailTo": "developer@servicebricks.com",
143-
"DevelopmentSmsTo": "1111111111"
146+
147+
// Send Notification Process
148+
"Send": {
149+
"TimerEnabled": false,
150+
"TimerIntervalMilliseconds": 7000,
151+
"TimerDueMilliseconds": 1000,
152+
"EmailFromDefault": "support@servicebricks.com",
153+
"SmsFromDefault": "1234567890",
154+
"IsDevelopment": false,
155+
"DevelopmentEmailTo": "developer@servicebricks.com",
156+
"DevelopmentSmsTo": "1234567890"
144157
},
145-
146-
// SMTP Email settings
158+
159+
// SMTP provider
147160
"Smtp": {
148-
"EmailServer": "yourserver.com",
149-
"EmailPort": 123,
150-
"EmailEnableSsl": true,
151-
"EmailUsername": "username",
152-
"EmailPassword": "password"
161+
"EmailServer": "yourserver.com",
162+
"EmailPort": 123,
163+
"EmailEnableSsl": true,
164+
"EmailUsername": "username",
165+
"EmailPassword": "password"
153166
},
154167

155-
// SendGrid Integration
168+
// ServiceBricks.Notification.SendGrid NuGet Package
156169
"SendGrid": {
157170
"ApiKey": "SendGridApiKey"
158171
}
@@ -165,5 +178,5 @@ When receiving the message, it will simply create a record in storage and allow
165178
# About ServiceBricks
166179

167180
ServiceBricks is the cornerstone for building a microservices foundation.
168-
Visit http://ServiceBricks.com to learn more.
181+
Visit https://ServiceBricks.com to learn more.
169182

0 commit comments

Comments
 (0)