Installation
Install the RabbitMQ hosting integration package in your AppHost project:Usage
Add RabbitMQ Resource
In your AppHost project (AppHost.cs), add a RabbitMQ resource:
Consume in Service
In your service project, reference the RabbitMQ resource using the client integration:Program.cs:
API Reference
AddRabbitMQ
Adds a RabbitMQ server resource to the application model. A container is used for local development.Parameters
name- The name of the resource. This name will be used as the connection string name when referenced in a dependency.userName- The parameter used to provide the user name for the RabbitMQ resource. Ifnulla default value will be used.password- The parameter used to provide the administrator password for the RabbitMQ resource. Ifnulla random password will be generated.port- The host port for RabbitMQ. If null, a random port will be assigned.
Returns
A reference to theIResourceBuilder<RabbitMQServerResource>.
Configuration Examples
Custom Port
Custom Credentials
Data Persistence with Volumes
RabbitMQ Management UI
RabbitMQ automatically includes a management UI that’s accessible via a separate endpoint:Named Volumes
Bind Mounts
Connection Properties
When you reference a RabbitMQ resource usingWithReference, the following connection properties are made available to the consuming project.
RabbitMQ Server
| Property Name | Description |
|---|---|
Host | The hostname or IP address of the RabbitMQ server |
Port | The port number the RabbitMQ server is listening on |
Username | The username for authentication |
Password | The password for authentication |
Uri | The connection URI, with the format amqp://{Username}:{Password}@{Host}:{Port} |
Environment Variables
Aspire exposes each property as an environment variable named[RESOURCE]_[PROPERTY]. For instance:
- The
Uriproperty of a resource calledmessagingbecomesMESSAGING_URI - The
Hostproperty becomesMESSAGING_HOST
Health Checks
The RabbitMQ hosting integration includes built-in health checks. When a resource is referenced as a dependency usingWaitFor, the dependent resource will wait until the RabbitMQ resource is able to service requests.