Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Transactional Outbox, Inbox & Idempotency

Distributed systems fail across network boundaries: a database commit can succeed before a message broker call fails, or a client retry can deliver the same command twice. The EricksonLopez.Outbox, EricksonLopez.Inbox, and EricksonLopez.Idempotency libraries enforce end-to-end delivery and replay invariants.

  • dotnet-outbox repository hosts both EricksonLopez.Outbox (3.0.0, published on NuGet) and EricksonLopez.Inbox / EricksonLopez.Inbox.Abstractions (3.0.0, published on NuGet). Note that EricksonLopez.Inbox.PostgreSql currently exists only in the local workspace (Unpublished).
  • dotnet-idempotency repository publishes EricksonLopez.Idempotency and EricksonLopez.Idempotency.Abstractions (2.0.0 on NuGet), plus PostgreSQL/Redis/EF Core/AspNetCore adapters.

DefaultOutbox serializes payloads with ArrayPoolBufferWriter<byte> and persists OutboxMessage records inside the caller’s IOutboxTransactionContext, guaranteeing that business state and outgoing events commit or roll back together:

using System;
using System.Threading;
using System.Threading.Tasks;
using EricksonLopez.Outbox;
using EricksonLopez.Outbox.Persistence;
namespace Example.Application.Orders;
public sealed record OrderConfirmedMessage(Guid OrderId, DateTimeOffset ConfirmedAt);
public sealed class OrderConfirmationService(IOutbox outbox)
{
public ValueTask PersistConfirmationEventAsync(
Guid orderId,
IOutboxTransactionContext transaction,
CancellationToken cancellationToken)
{
var message = new OrderConfirmedMessage(orderId, DateTimeOffset.UtcNow);
return outbox.StoreAsync(message, transaction, cancellationToken);
}
}

Because outbox dispatchers guarantee at-least-once delivery, downstream consumers use IIdempotencyChecker and IInboxStore (EricksonLopez.Inbox.Abstractions) so duplicate message deliveries do not re-apply side effects.

For HTTP/API and mediator commands, IdempotencyEngine (EricksonLopez.Idempotency) uses atomic ClaimResultStatus leases (IIdempotencyStore) and request payload fingerprinting (IdempotencyFingerprintHasher) to:

  • Execute the handler once when the idempotency key is first claimed.
  • Return the cached ExecutionResponse on safe retries with identical payload fingerprints.
  • Reject conflicting payload reuse with IdempotencyConflictException / IdempotencyProblemDetails.