Atya.Messaging.Outbox 2.0.0

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

Atya.Messaging.Outbox

Transactional outbox store and relay primitives for reliable Atya messaging.

NuGet Build

Overview

Atya.Messaging.Outbox captures messages in an outbox store through the existing IMessagePublisher<TMessage> contract, then relays pending messages through a transport publisher later. The package includes contracts, serialization helpers, an in-memory store for tests and simple hosts, and a relay that preserves message id, correlation id, headers, and runtime message type. Delivery uses atomic claims with leases, backoff and sanitized failure diagnostics; failures that exhaust the attempt budget are marked Failed.

Entity Framework and broker-specific providers are intentionally out of scope for this package.

Installation

dotnet add package Atya.Messaging.Outbox

Quick Start

using Atya.Messaging.Abstractions;
using Atya.Messaging.Outbox;

var registry = new OutboxContractRegistry().Register<OrderSubmitted>("orders.submitted", schemaVersion: 1);
var store = new InMemoryOutboxStore(TimeProvider.System);
var outboxPublisher = new OutboxPublisher<OrderSubmitted>(store, TimeProvider.System, new OutboxMessageSerializer(registry));

await outboxPublisher.PublishAsync(
    new OrderSubmitted("order-123"),
    new MessagePublishOptions(messageId: "message-123", correlationId: "correlation-123"));

IMessagePublisher transportPublisher = /* adapter implemented by a transport package */;
var relay = new OutboxRelay(store, transportPublisher, TimeProvider.System, registry, new OutboxRelayOptions());
OutboxRelayResult result = await relay.PublishPendingAsync();

public sealed record OrderSubmitted(string OrderId);

Public Surface

  • IOutboxStore stores messages and arbitrates delivery: ClaimAsync atomically claims a batch under one OutboxClaimToken and lease; RenewAsync, MarkPublishedAsync and MarkFailedAsync are compare-and-set on the token and return OutboxTransition (Applied, ClaimLost, NotFound). Durable implementations must make AddAsync participate in the caller's transaction.
  • OutboxMessage carries a contract name and schema version (never a CLR type name), NextAttemptAt, claim owner/token/expiry and a sanitized LastFailure. OutboxMessageStatus has Pending, Claimed, Published and terminal Failed.
  • OutboxContractRegistry maps ("orders.submitted", 1) to a type by dictionary lookup; there is no Type.GetType fallback and the registry is frozen on first use. Upcasters are not provided: an unknown name or version is a terminal failure.
  • OutboxRelay claims, renews the lease when under half remains, publishes, and acknowledges. Failures back off as min(Max, Initial * Factor^(attempt-1)) with JitterFactor jitter (set 0 in tests). Unknown contracts and undeserializable payloads are terminal immediately; other failures are terminal after MaxAttempts.
  • OutboxFailure persists the exception type, a bounded and redacted description (type name only unless DescribeFailure supplies more) and a handle under which the full exception is logged. No stack trace is persisted.
  • InMemoryOutboxStore is an ephemeral, single-process store for tests and contract exercises. It is not a production outbox and does not enlist in transactions; the contract is the OutboxStoreConformanceTests suite.

Delivery guarantee

Delivery is at least once. If acknowledging fails after a successful publish, no failure is recorded: the lease lapses and the message is sent again. Pair consumers with the Idempotency package keyed on the message id.

Hosting recipe

Run the relay on PeriodicBackgroundService from Atya.Hosting.BackgroundServices 2.0 (a recipe, not a package): derive a worker whose ExecuteIterationAsync calls relay.PublishPendingAsync(cancellationToken), register it with AddAtyaBackgroundService<RelayWorker>(o => o.Interval = TimeSpan.FromSeconds(2)), and note that failures inside the relay are recorded per message, not thrown.

Migrating from 1.x to 2.0

  • Breaking for store implementers (claim-based contract), for code constructing OutboxRelay (takes TimeProvider, a registry and options) and for stored data.
  • Register every message type with a contract name; rows written by 1.x carry assembly-qualified names. No mapping helper is shipped (no durable store exists yet), so 1.x pending rows become terminal "unknown contract" failures.
  • OutboxMessage.LastError became LastFailure; OutboxMessageSerializer.ResolveMessageType was removed; Atya.Foundation.Time is no longer used.
  • Last compatible version: 1.0.0.

Testing

dotnet test

Benchmarks

dotnet run -c Release --project benchmarks/Outbox.Benchmarks

License

MIT. See LICENSE.

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
2.0.0 186 11/28/2026
1.0.0 371 7/13/2026