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
<PackageReference Include="MVFC.Aspire.Helpers.RabbitMQ" Version="9.0.3" />
<PackageVersion Include="MVFC.Aspire.Helpers.RabbitMQ" Version="9.0.3" />
<PackageReference Include="MVFC.Aspire.Helpers.RabbitMQ" />
paket add MVFC.Aspire.Helpers.RabbitMQ --version 9.0.3
#r "nuget: MVFC.Aspire.Helpers.RabbitMQ, 9.0.3"
#:package MVFC.Aspire.Helpers.RabbitMQ@9.0.3
#addin nuget:?package=MVFC.Aspire.Helpers.RabbitMQ&version=9.0.3
#tool nuget:?package=MVFC.Aspire.Helpers.RabbitMQ&version=9.0.3
MVFC.Aspire.Helpers.RabbitMQ
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.jsonwith exchanges/queues/bindings. - Manually loading that file or running
rabbitmqctlcommands. - 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(...)andWithQueues(...)to declare topology from code.WithDataVolume(...)andWithCredentials(...)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
MVFC.Aspire.Helpers.RabbitMQ: Helpers and extensions library for RabbitMQ.
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 (default5672).httpPort(optional): Management UI port (default15672).
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 | Versions 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. |
-
net10.0
- Aspire.Hosting (>= 13.1.2)
-
net9.0
- Aspire.Hosting (>= 13.1.2)
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 |