GM.Messaging.Persistence 1.3.1

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

<p align="center"> <img src="https://raw.githubusercontent.com/gmetskhvarishvili/GM.Messaging/master/icon.png" alt="GM.Messaging" width="140" height="140" /> </p>

GM.Messaging

CI NuGet License: MIT

A lightweight messaging setup for .NET built on Wolverine and RabbitMQ. One call wires up the message bus from configuration — connection, resilience (retry + circuit breaker), and producer/consumer topology — with a transactional outbox/inbox for reliable, exactly-once-style integration events. Part of the GM.* family of packages. Targets net10.0.

Packages

This repository ships three packages that version and release in lockstep:

Package What it provides
GM.Messaging AddGMMessaging — Wolverine + RabbitMQ wiring, resilience, topology, and the outbox relay worker.
GM.Messaging.Domain IntegrationEvent, and the InboxMessage / OutboxMessage entities.
GM.Messaging.Persistence EF Core configurations + an inbox store/processor.

Install

dotnet add package GM.Messaging

Register

using GM.Messaging;

builder.Services.AddGMMessaging(builder.Configuration);

Configure

Everything comes from the Messaging configuration section (shape matches MessagingOptions); every value has a sensible default:

{
  "Messaging": {
    "ServiceName": "orders-service",
    "RabbitMq": {
      "HostName": "localhost",
      "Port": 5672,
      "VirtualHost": "/",
      "UserName": "guest",
      "Password": "guest"
    },
    "Retry": { "MaxAttempts": 5, "InitialDelayMilliseconds": 250 },
    "CircuitBreaker": { "Enabled": true, "FailurePercentageThreshold": 25 },
    "OutboxRelay": { "BatchSize": 50, "PollingIntervalSeconds": 5 }
  }
}

Optional ProducerTopology / ConsumerTopology sections declare exchange/queue routes, and the configureWolverine callback on AddGMMessaging lets you customize Wolverine directly.

Publish an integration event

public record OrderPlaced(Guid OrderId) : IntegrationEvent;

// persist via the outbox for reliable delivery
var outbox = OutboxMessage.From(new OrderPlaced(orderId));
dbContext.Set<OutboxMessage>().Add(outbox);
await dbContext.SaveChangesAsync();

The outbox relay worker picks up unprocessed OutboxMessages and publishes them through Wolverine; the inbox deduplicates and tracks consumed messages per consumer.

Wire the outbox and inbox

Both stores work directly on your DbContext, so your repositories don't need to implement any GM.Messaging interfaces:

// Producer: starts the relay worker and gives it an outbox store over AppDbContext
builder.Services.AddGMOutboxRelay<OutboxMessage, AppDbContext>();

// Consumer: registers IInboxProcessor and an inbox store over AppDbContext
builder.Services.AddGMInbox<InboxMessage, AppDbContext>();

TOutboxMessage / TInboxMessage can be your own subclasses of the base entities; a private parameterless constructor is enough. To use a custom store instead, register your IOutboxDbContext<T> / IInboxStore<T> before these calls (or call AddGMInboxProcessor<T>() on its own).

Run the relay in one process only

AddGMOutboxRelay starts a background worker that polls the outbox table. Register it only in the process that should publish, typically a dedicated worker. If several processes run it against the same table (say an API and a worker that share a persistence setup), two pollers can pick up the same rows before either marks them processed, and those messages get published twice.

When the API and the worker share one persistence registration method, pass a flag through it and turn the relay on only in the worker:

public static IServiceCollection AddPersistence(
    this IServiceCollection services, IConfiguration configuration, bool runOutboxRelay = false)
{
    // ... DbContext and repositories ...

    if (runOutboxRelay)
        services.AddGMOutboxRelay<OutboxMessage, AppDbContext>();

    return services;
}

// Worker:  builder.Services.AddPersistence(builder.Configuration, runOutboxRelay: true);
// API:     builder.Services.AddPersistence(builder.Configuration);

The project that calls AddGMOutboxRelay needs the GM.Messaging package, not just GM.Messaging.Persistence. If you'd rather keep the persistence layer on GM.Messaging.Persistence alone, call AddGMOutboxRelay from the worker's Program.cs instead.

Local infrastructure

A docker-compose.yml is included to run PostgreSQL + RabbitMQ locally:

docker compose up gm.messaging.postgres gm.messaging.rabbitmq

Requirements

  • .NET 10 SDK
  • RabbitMQ (and a relational database for the outbox/inbox).

Contributing & releases

Versioning is automated from Conventional Commits — see CONTRIBUTING.md. All three packages release together under one version.

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

Showing the top 1 NuGet packages that depend on GM.Messaging.Persistence:

Package Downloads
GM.Messaging

A lightweight messaging setup for .NET built on Wolverine and RabbitMQ. One call (AddGMMessaging) wires up the message bus with config-driven RabbitMQ connection, resilience (retry + circuit breaker) and producer/consumer topology, plus an outbox relay that retries with backoff, dead-letters, leases messages so it can run in several processes, cleans up old rows and continues traces. Part of the GM.Messaging family.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0 106 11/17/2026
4.14.0 174 11/17/2026
4.13.0 97 11/17/2026
4.12.0 97 11/17/2026
4.11.0 99 11/17/2026
4.10.0 193 11/17/2026
4.9.0 97 11/17/2026
4.8.0 100 11/17/2026
4.7.0 100 11/17/2026
4.6.0 172 11/17/2026
4.5.0 115 11/16/2026
4.4.0 134 11/16/2026
4.3.0 148 11/16/2026
4.2.0 129 11/16/2026
4.1.0 204 11/16/2026
4.0.0 123 11/16/2026
3.0.0 164 11/16/2026
2.0.1 100 11/16/2026
2.0.0 107 11/16/2026
1.3.1 131 11/15/2026
Loading failed