ReportOutBox is a notification service that processes notifications in the background using the Outbox Pattern. The system stores events in the outbox table and processes them asynchronously to send notifications (e.g., email or system alerts). The service is built to be resilient, ensuring that messages are not lost even in the case of failures.
This project is built using the following technologies:
- .NET 6 (or later)
- Background Services for handling message dispatching
- In-Memory Database for data storage (you can switch to SQL Server if needed)
- ASP.NET Core for the API layer
Make sure the following software is installed on your machine:
- .NET 6 (or later)
Clone the repository to your local machine:
git clone https://github.com/AlexGreatDev/OutboxWebApp.git
cd OutboxWebApp
Install the necessary packages:
dotnet restore
The project is configured to use an In-Memory Database by default, which is perfect for development and testing. If you want to use SQL Server, you can modify the Startup.cs
or Program.cs
to configure a SQL Server connection string.
Example:
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer("Your_Connection_String_Here"));
Run the application using the following command:
dotnet run
This will start both the API and the background service.
The Notification Background Service runs automatically when the application starts. This service listens for new notifications and processes them asynchronously.
The Notification Controller exposes an API to manage notifications. You can interact with it to send notifications and retrieve status.
Example of endpoint:
- POST
/api/notifications/send
– Triggers a notification event.
You can run the tests using the following command:
dotnet test
Tests are used to ensure that the notification service works correctly, and the background service processes messages as expected.
-
Outbox Pattern: This service follows the Outbox Pattern to ensure reliable messaging. When a notification is triggered, it's stored in the outbox table and processed by the background service. This ensures that no messages are lost, even if there's a failure in the system.
-
Background Processing: The system uses background services to handle long-running tasks asynchronously without blocking the main application.
-
Data Storage: For simplicity, an In-Memory Database is used for this project. If needed, you can switch to a persistent SQL Server database by adjusting the configuration in the code.