Middenly.Outbox 1.0.1

dotnet add package Middenly.Outbox --version 1.0.1
                    
NuGet\Install-Package Middenly.Outbox -Version 1.0.1
                    
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="Middenly.Outbox" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Middenly.Outbox" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Middenly.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 Middenly.Outbox --version 1.0.1
                    
#r "nuget: Middenly.Outbox, 1.0.1"
                    
#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 Middenly.Outbox@1.0.1
                    
#: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=Middenly.Outbox&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Middenly.Outbox&version=1.0.1
                    
Install as a Cake Tool

Middenly.Outbox

NuGet License: MIT

Transactional Outbox pattern implementation for Confluent.Kafka with PostgreSQL support.

Overview

The Outbox pattern ensures reliable message delivery by storing outgoing messages in a local database table (the "outbox") within the same transaction as your business data. A separate background process then reads and dispatches these messages to Kafka.

This approach guarantees at-least-once delivery and avoids dual-write problems in microservice architectures.

Key Features

  • Transactional Outbox - Store messages in PostgreSQL alongside your business data
  • Confluent.Kafka Integration - Native Kafka producer with full header and partition support
  • EF Core Integration - Atomic SaveChanges with UseEfCoreOutbox<T>()
  • Per-Topic Configuration - Fluent API for ordering, retries, producer profiles
  • Background Dispatcher - Automatic polling and delivery with configurable intervals
  • Retry with Dead Letter - Configurable retry policies with dead letter queue support
  • Delayed Delivery - Schedule messages for future delivery
  • Parallel Delivery - Per-topic concurrent dispatching with Kafka internal batching
  • Pessimistic Locking - FOR UPDATE SKIP LOCKED for safe concurrent access
  • Stuck Message Recovery - Automatic recovery of InProgress messages after crashes
  • Extensible Serialization - Pluggable serializer interface (System.Text.Json included)

Installation

dotnet add package Middenly.Outbox

Package Manager

Install-Package Middenly.Outbox

Quick Start

1. Register Services

using Middenly.Outbox.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddOutbox(options =>
{
    options.BatchSize = 100;
    options.PollingInterval = TimeSpan.FromSeconds(5);
    options.MaxAttempts = 5;
    options.EnableDeadLetter = true;
})
.UsePostgresStore(builder.Configuration.GetConnectionString("Default")!)
.UseKafkaProducer(kafka =>
{
    kafka.BootstrapServers = "localhost:9092";
    kafka.Acks = Confluent.Kafka.Acks.All;
    kafka.EnableIdempotence = true;
});

2. Use in Your Service

using Middenly.Outbox.Abstractions;

public class OrderService
{
    private readonly IOutbox _outbox;

    public OrderService(IOutbox outbox)
    {
        _outbox = outbox;
    }

    public async Task CreateOrderAsync(Order order)
    {
        // Save order to database...

        // Publish event — serializer is resolved automatically
        await _outbox.PublishAsync("order-events", new OrderCreatedEvent
        {
            OrderId = order.Id,
            Total = order.Total,
            CreatedAt = DateTimeOffset.UtcNow
        });
    }
}

3. Advanced Usage

// Publish with key, partition, headers via fluent options
await _outbox.PublishAsync("order-events", new OrderCreatedEvent { ... }, opts =>
{
    opts.WithKey(order.Id.ToString());
    opts.WithPartition(0);
    opts.WithHeader("correlation-id", requestId);
    opts.DeliverAfterDelay(TimeSpan.FromMinutes(30));
});

Requirements

  • .NET 10.0+
  • PostgreSQL 12+
  • Kafka (Confluent.Kafka compatible)

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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

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.0.1 128 6/11/2026
1.0.0 118 6/11/2026