MVFC.Aspire.Helpers.RabbitMQ 9.0.3

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

MVFC.Aspire.Helpers.RabbitMQ

🇧🇷 Leia em Português

CI codecov License Platform NuGet Version NuGet Downloads

Helper for integrating with RabbitMQ in .NET Aspire projects, including automatic creation of exchanges, queues, and dead letter queues.

Motivation

Using RabbitMQ in local environments often requires:

  • Maintaining a definitions.json with exchanges/queues/bindings.
  • Manually loading that file or running rabbitmqctl commands.
  • Repeating configuration for each Aspire solution.

With .NET Aspire you can start a RabbitMQ container, but you still need to:

  • Configure users/passwords and management UI.
  • Declare exchanges, queues and DLQs consistently.
  • Keep connection details in sync with your applications.

MVFC.Aspire.Helpers.RabbitMQ wraps this into a fluent API:

  • AddRabbitMQ(...) to provision RabbitMQ in Aspire.
  • WithExchanges(...) and WithQueues(...) to declare topology from code.
  • WithDataVolume(...) and WithCredentials(...) for persistence and security.
  • project.WithReference(rabbitMQ) to wire your services to the broker.

Overview

MVFC.Aspire.Helpers.RabbitMQ is an extension library for .NET Aspire that facilitates integration with RabbitMQ. It provides extension methods to add RabbitMQ resources to your Aspire application, configure exchanges, queues, and dead letter queues, and setup references between projects.

Project Structure

Features

  • Adds a configured RabbitMQ container.
  • Support for custom exchanges and queues via ExchangeConfig/QueueConfig.
  • Support for dead letter exchanges (DLX).
  • Support for message TTL per queue.
  • Support for data persistence via Docker volume.
  • Support for custom credentials.
  • Support for the RabbitMQ Management UI.

Compatible Images

  • rabbitmq

Installation

dotnet add package MVFC.Aspire.Helpers.RabbitMQ

Quick Aspire usage (AppHost)

using Aspire.Hosting;
using MVFC.Aspire.Helpers.RabbitMQ;

var builder = DistributedApplication.CreateBuilder(args);

var rabbitMQ = builder.AddRabbitMQ("rabbitmq")
    .WithCredentials(username: "admin", password: "password")
    .WithExchanges([
        new ExchangeConfig("test-exchange", "topic"),
        new ExchangeConfig("dead-letter", "fanout")
    ])
    .WithQueues([
        new QueueConfig("test-queue", ExchangeName: "test-exchange", RoutingKey: "test.*", DeadLetterExchange: "dead-letter"),
        new QueueConfig("empty-queue", ExchangeName: "test-exchange", RoutingKey: "empty.*"),
        new QueueConfig("dlq", ExchangeName: "dead-letter")
    ])
    .WithDataVolume("rabbit-mq");

builder.AddProject<Projects.MVFC_Aspire_Helpers_Playground_Api>("api-example")
       .WithReference(rabbitMQ)
       .WaitFor(rabbitMQ);

await builder.Build().RunAsync();

Provisioning diagram

sequenceDiagram
    participant Aspire as .NET Aspire
    participant Container as RabbitMQ Container
    participant Configurator as RabbitMQ Processor
    
    Aspire->>Container: Start container (rabbitmq:management)
    Container-->>Aspire: Ready (AMQP port 5672 available)
    Aspire->>Configurator: Trigger OnResourceReady
    Configurator->>Container: Create Exchanges
    Configurator->>Container: Create Queues
    Configurator->>Container: Bind Queues to Exchanges
    Configurator-->>Aspire: Provisioning Completed
    Aspire->>App: Start App with AMQP ConnectionString

AddRabbitMQ parameters

  • name: RabbitMQ resource name.
  • amqpPort (optional): AMQP port (default 5672).
  • httpPort (optional): Management UI port (default 15672).

Fluent methods

Method Description
WithDockerImage(image, tag) Overrides the Docker image used.
WithCredentials(username, password) Defines username and password.
WithExchanges(exchanges) Configures exchanges to be created.
WithQueues(queues) Configures queues to be created.
WithDataVolume(volumeName) Enables persistence with Docker volume.

Exchanges and queues configuration

ExchangeConfig

Parameter Type Default Description
Name string Exchange name.
Type string "direct" Type: direct, topic, fanout, headers.
Durable bool true Durable across restarts.
AutoDelete bool false Auto delete when unused.

QueueConfig

Parameter Type Default Description
Name string Queue name.
ExchangeName string? null Exchange to which the queue will be bound.
RoutingKey string? null Binding routing key (default: queue name).
Durable bool true Durable across restarts.
AutoDelete bool false Auto delete when unused.
DeadLetterExchange string? null Dead letter exchange.
MessageTTL int? null Message TTL in milliseconds.

Other optional parameters

  • connectionStringSection (optional):
    Path to the configuration section containing the RabbitMQ connection string.
    Default: "ConnectionStrings:rabbitmq".
{
  "ConnectionStrings": {
    "rabbitmq": "localhost:5672"
  }
}

Requirements

  • .NET 9+
  • Aspire.Hosting >= 9.5.0

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
9.0.3 97 4/12/2026
9.0.2 88 4/12/2026
9.0.1 89 4/12/2026
9.0.0 101 4/12/2026
8.0.2 91 4/11/2026
8.0.1 102 4/3/2026
8.0.0 97 4/2/2026
7.3.3 99 3/31/2026
7.3.2 95 3/30/2026
7.3.1 99 3/30/2026
7.3.0 99 3/30/2026
7.2.2 96 3/29/2026
7.2.1 97 3/29/2026
7.2.0 93 3/29/2026
7.1.0 92 3/22/2026
6.4.4 94 3/21/2026
6.4.3 96 3/15/2026
6.4.2 97 3/15/2026
6.4.1 99 3/10/2026
6.4.0 97 3/9/2026
Loading failed