DotEventOutbox 1.1.0
See the version list below for details.
dotnet add package DotEventOutbox --version 1.1.0
NuGet\Install-Package DotEventOutbox -Version 1.1.0
<PackageReference Include="DotEventOutbox" Version="1.1.0" />
paket add DotEventOutbox --version 1.1.0
#r "nuget: DotEventOutbox, 1.1.0"
// Install DotEventOutbox as a Cake Addin #addin nuget:?package=DotEventOutbox&version=1.1.0 // Install DotEventOutbox as a Cake Tool #tool nuget:?package=DotEventOutbox&version=1.1.0
DotEventOutbox
Overview
DotEventOutbox is a powerful .NET library created to enhance the implementation of the outbox pattern, integrating seamlessly with MediatR and Entity Framework. This library is key in ensuring that domain events are processed in a reliable, consistent, and idempotent manner.
Key Features
- Seamless Integration with MediatR and Entity Framework: DotEventOutbox provides an effortless and smooth integration for managing and dispatching domain events using MediatR and Entity Framework.
- Idempotent Processing: Guarantees that each event is processed exactly once, thereby preventing any possibility of duplicate event handling.
- Advanced Outbox Message Management: Automates the conversion, storage, and lifecycle management of domain events into outbox messages.
- Robust Dead Letter Queue: Implements a system to manage failed messages, allowing for their later analysis or reprocessing.
- Quartz Integration: Provides an automated and scheduled approach to outbox message processing using Quartz.
- Configurable Settings: Offers a wide range of customizable settings through
EventOutboxSettings
to tailor the outbox behavior to your specific needs.
Installation
Install DotEventOutbox via NuGet:
Install-Package DotEventOutbox
Or through the .NET Core CLI:
dotnet add package DotEventOutbox
Both commands will download and install DotEventOutbox along with all necessary dependencies.
Contracts-Only Package
For projects needing only the contracts of DotEventOutbox, such as IEvent
, DomainEvent
, and IDomainEventEmitter
, use the DotEventOutbox.Contracts package:
dotnet add package DotEventOutbox.Contracts
This is ideal for separating DotEventOutbox contracts from their handlers in different assemblies or projects.
Service Registration
Register DotEventOutbox services easily with IServiceCollection
:
services.AddDotEventOutbox(configuration,
options => options.UseNpgsql(configuration.GetConnectionString("AppDb")));
Database Migration
Create necessary tables by executing:
await app.MigrateDotEventOutbox();
This will create OutboxMessages
, OutboxMessageConsumers
, and DeadLetterMessages
tables.
Configuration Details
Customize DotEventOutbox using these settings:
- ProcessingIntervalInSeconds: Time interval for processing outbox messages.
- MaxMessagesProcessedPerBatch: Maximum number of messages processed per batch.
- RetryIntervalInMilliseconds: Time delay between retry attempts for failed messages.
- MaxRetryAttempts: Maximum retry attempts before moving a message to the dead-letter queue.
Example appsettings.json
:
{
"ConnectionStrings": {
"AppDb": "Your-Database-Connection-String"
},
"DotEventOutbox": {
"ProcessingIntervalInSeconds": 10,
"MaxMessagesProcessedPerBatch": 10,
"RetryIntervalInMilliseconds": 50,
"MaxRetryAttempts": 3
}
}
Example Usage
Here's a basic example in a console application:
// Program.cs
// Create a new user instance
var user = new User(Guid.NewGuid(), "John Doe", "John.Doe@Demo.com");
// Raise the UserCreatedDomainEvent
user.RaiseEvent(new UserCreatedDomainEvent(user.Name, user.Email));
// Add the new user to the DbContext
dbContext.Users.Add(user);
// Save changes and process domain events using OutboxCommitProcessor
var outboxCommitProcessor = scope.ServiceProvider.GetRequiredService<IOutboxCommitProcessor>();
await outboxCommitProcessor.ProcessAndSaveAsync(dbContext);
For a comprehensive example, visit the Demo Repository.
Contributing
Contributions and suggestions are highly appreciated. Please review our Contributing Guidelines for detailed information on how to participate.
License
DotEventOutbox is open-sourced under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- DotEventOutbox.Contracts (>= 1.0.1)
- MediatR (>= 12.2.0)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Polly (>= 8.2.0)
- Quartz (>= 3.8.0)
- Quartz.Extensions.Hosting (>= 3.8.0)
- Scrutor (>= 4.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.