SimpleTransitRabbitMQ 3.0.8

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

SimpleTransit

⚠️ Deprecated Plugin Removed: The x-delayed-message plugin is no longer used. ✅ Plugin-Free Retry: Messages now use manual retry queues with TTL/DLX.

SimpleTransit is a lightweight RabbitMQ-based messaging library for .NET, designed to be simple, explicit, and framework-friendly. It provides easy configuration of receive endpoints, retry policies, and automatic handler discovery using ASP.NET Core dependency injection.

✨ Features

  • 🚀 Simple RabbitMQ integration
  • 🔁 Built-in retry support with delay
  • 📦 Strongly-typed events
  • 🧩 Automatic handler registration via assembly scanning
  • ⚙️ Minimal configuration, no magic

Installation

Install via NuGet:

dotnet add package SimpleTransitRabbitMQ

Example appsettings.json:

{
  "ConnectionStrings": {
    "Rabbit": "amqp://guest:guest@localhost:5672/"
  }
}

Basic Usage

  1. Define an Event

All events must inherit from Event.

using SimpleTransit;

namespace bxgamble.Services.SimpleTransitEvents;

public class TestEvent : Event
{
    public required string Message { get; set; }
}
  1. Configure SimpleTransit
public static WebApplicationBuilder ConfigureSimpleTransit(this WebApplicationBuilder builder)
{
    builder.Services.AddSimpleTransit(
        rabbitMQConnectionString: builder.Configuration.GetConnectionString("Rabbit")
            ?? throw new InvalidOperationException("RabbitMQ connection string is not configured."),

        new SimpleTransitOptions().AddReceiveEndpoint(
            new ReceiveEndpointOptions
            {
                Event = typeof(TestEvent),
                Durable = true,
                AutoDelete = false,
                PrefetchCount = 100,
                RetryPolicy = new RetryPolicy
                {
                    Count = 2,
                    Delay = TimeSpan.FromSeconds(2)
                }
            }
        ),

        typeof(Program).Assembly
    );

    return builder;
}

Publishing Events

SimpleTransit provides an explicit publishing abstraction via IEventBus.

IEventBus Interface

namespace SimpleTransit;

public interface IEventBus
{
    Task PublishAsync<T>(T @event, CancellationToken cancellationToken)
        where T : Event;
}

Publishing an Event

To publish an event, inject IEventBus and call PublishAsync.

public class TestService(IEventBus eventBus)
{
    public async Task SendAsync(CancellationToken cancellationToken)
    {
        var @event = new TestEvent
        {
            Message = "Hello from SimpleTransit"
        };

        await eventBus.PublishAsync(@event, cancellationToken);
    }
}

Event Headers

Every event in SimpleTransit contains a Header object that holds metadata about message lifecycle and failures.

Header Structure

public class Header
{
    public Guid Id { get; init; }
    public DateTimeOffset OccurredAt { get; init; }
    public int RetryCount { get; set; }

    // Optional exception info after failure
    public SimpleTransitError? Error { get; set; }
}

Receive Endpoints

A Receive Endpoint defines how an event is consumed from RabbitMQ. Available Options

Property Description
Event Event type handled by this endpoint
Durable Whether the queue survives broker restarts
AutoDelete Whether the queue is deleted when unused
PrefetchCount Maximum unacknowledged messages per consumer
RetryPolicy Retry behavior on handler failure

Retry Policy

SimpleTransit supports message retry with delay.

RetryPolicy = new RetryPolicy
{
    Count = 2,
    Delay = TimeSpan.FromSeconds(2)
}

Behavior:

Message is retried up to Count times Delay is applied between retries After retries are exhausted, the message is dropped

Event Handlers

Handlers are discovered automatically from the provided assembly. All handlers must implement IEventHandler<TEvent>.

Example Handler

public class TestEventHandler : IEventHandler<TestEvent>
{
    public Task HandleAsync(TestEvent message)
    {
        Console.WriteLine(message.Message);
        return Task.CompletedTask;
    }
}

Assembly Scanning

Handlers are registered automatically from the specified assembly:

typeof(Program).Assembly

This allows:

  • Clean separation of events and handlers
  • Zero manual DI registration

Acknowledgement Behavior

Messages are ACKed only after successful handler execution On exception retry policy is applied After retries, the message is NACKed

Custom JSON Serialization

SimpleTransit allows you to fully customize JSON serialization by providing your own JsonSerializerOptions.

📄 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
3.0.8 88 3/1/2026
2.0.0 291 12/19/2025