LinKit.Outbox 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LinKit.Outbox --version 1.0.0
                    
NuGet\Install-Package LinKit.Outbox -Version 1.0.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="LinKit.Outbox" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LinKit.Outbox" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LinKit.Outbox" />
                    
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 LinKit.Outbox --version 1.0.0
                    
#r "nuget: LinKit.Outbox, 1.0.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 LinKit.Outbox@1.0.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=LinKit.Outbox&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LinKit.Outbox&version=1.0.0
                    
Install as a Cake Tool

LinKit.Outbox

NuGet Version NuGet Downloads

LinKit.Outbox provides high-performance, zero-reflection, and Native AOT compatible primitives for implementing the Transactional Outbox and Idempotent Inbox patterns in distributed .NET systems.

Guarantees At-Least-Once Delivery and Exactly-Once Processing across microservices and modular monoliths without runtime reflection or heavy external dependencies.


🚀 Key Features

  • Zero Reflection & Native AOT Ready: All serializers and handlers run with compile-time safety and zero reflection overhead.
  • Database Agnostic: Works seamlessly with Entity Framework Core, Dapper, Marten, or raw ADO.NET.
  • Transactional Outbox: Reliably records outgoing integration messages within the business transaction boundary.
  • Idempotent Inbox: Automatically deduplicates incoming messages to protect business logic against duplicate event deliveries.
  • Optimized Background Worker: Efficient periodic polling with exponential backoff and batch dispatching.

📦 Installation

dotnet add package LinKit.Outbox

🛠️ Usage Guide

1. Store Outbox Messages in Business Transactions

When executing your CQRS Command Handler, record the outbox message inside the same database transaction:

using LinKit.Outbox;

public class CreateOrderHandler : ICommandHandler<CreateOrderCommand, Guid>
{
    private readonly IOutboxStore _outboxStore;
    private readonly AppDbContext _db;

    public CreateOrderHandler(IOutboxStore outboxStore, AppDbContext db)
    {
        _outboxStore = outboxStore;
        _db = db;
    }

    public async Task<Guid> HandleAsync(CreateOrderCommand command, CancellationToken ct)
    {
        var order = new Order(command.CustomerId, command.Amount);
        _db.Orders.Add(order);

        // Stage outbox message in the same local transaction
        await _outboxStore.SaveMessageAsync(new OutboxMessage
        {
            Id = Guid.NewGuid(),
            MessageType = typeof(OrderCreatedIntegrationEvent).AssemblyQualifiedName!,
            Payload = JsonSerializer.Serialize(new OrderCreatedIntegrationEvent(order.Id), AppJsonSerializerContext.Default.OrderCreatedIntegrationEvent),
            CreatedAt = DateTimeOffset.UtcNow
        }, ct);

        await _db.SaveChangesAsync(ct);
        return order.Id;
    }
}

2. Idempotent Inbox Consumer

Prevent duplicate execution when consuming messages:

using LinKit.Outbox;

public class OrderCreatedIntegrationEventHandler : ICommandHandler<OrderCreatedIntegrationEvent>
{
    private readonly IInboxStore _inboxStore;

    public OrderCreatedIntegrationEventHandler(IInboxStore inboxStore)
    {
        _inboxStore = inboxStore;
    }

    public async Task HandleAsync(OrderCreatedIntegrationEvent evt, CancellationToken ct)
    {
        // Check if message was already processed
        if (await _inboxStore.HasProcessedAsync(evt.MessageId, ct))
        {
            return; // Skip duplicate message safely
        }

        // Execute idempotently
        await ProcessOrderAsync(evt, ct);

        // Mark as processed
        await _inboxStore.MarkProcessedAsync(evt.MessageId, ct);
    }
}

3. Register Services in Program.cs

using LinKit.Outbox;

var builder = WebApplication.CreateBuilder(args);

// Register LinKit Core & Outbox
builder.Services.AddLinKitCqrs();
builder.Services.AddLinKitOutbox<MySqlOutboxStore, MySqlInboxStore>(options =>
{
    options.BatchSize = 100;
    options.PollIntervalSeconds = 5;
    options.MaxRetries = 3;
});

📄 License

Licensed 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.  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 (1)

Showing the top 1 NuGet packages that depend on LinKit.Outbox:

Package Downloads
LinKit.Outbox.Data

Provider-neutral ADO.NET durable stores for LinKit Outbox and Inbox.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 98 10/31/2026
1.2.0 103 10/30/2026
1.1.0 107 10/22/2026
1.0.0 102 10/20/2026