DotEventOutbox 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotEventOutbox --version 1.1.0
NuGet\Install-Package DotEventOutbox -Version 1.1.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="DotEventOutbox" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotEventOutbox --version 1.1.0
#r "nuget: DotEventOutbox, 1.1.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.
// 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 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. 
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.1.1 40 5/20/2024
1.1.0 210 12/26/2023
1.0.5 116 12/26/2023
1.0.4 128 12/25/2023
1.0.3 108 12/24/2023
1.0.2 112 12/22/2023
1.0.1 115 12/22/2023
1.0.0 110 12/21/2023