Easily leverage RabbitMQ's Delayed Message Exchange Plugin in Aspire hosted applications
$ dotnet add package Aspire4RabbitMQDelayedMessageExchangeAn easy way to leverage RabbitMQ's Delayed Message Exchange Plugin in Aspire hosted applications using just one line of code. This allows you to use NServiceBus or MassTransit or the .NET messaging library of your choice with RabbitMQ and have the ability to delay delivery of messages. Don't need the source code? Just get the Nuget package: https://www.nuget.org/packages/Aspire4RabbitMQDelayedMessageExchange/
.NET Aspire supports the official Management Plugin for RabbitMQ, adding a web GUI for inspecting queues and exchanges of the popular message broker. However, it currently doesn't currently (as of early 2025) support adding the Delayed Message Exchange Plugin.
My little library Aspire4RabbitMQDelayedMessageExchange solves the problem by writing a docker file to a temporary location inside your AppHost for you and running it in Docker as part of your distributed application.
AddRabbitMQ chain a call to WithDelayedDeliveryPlugin.var builder = DistributedApplication.CreateBuilder(args);
var rabbitMQ = builder.AddRabbitMQ(AspireResourceNames.MessageBroker.ConnectionName)
.WithDataVolume()
.WithLifetime(ContainerLifetime.Persistent)
.WithManagementPlugin()
.WithDelayedMessageExchangePlugin();
You can pass a tag argument to the WithDelayedMessageExchangePlugin method if you like. This will force a particular version of the plugin to be installed (e.g. "3.0" or "4.0") rather than the default, which is "latest".
If I find and overcome any hurdles I'll mention them here, but it's early days. So far so good.
I'm a hobbyist. I know there are loads of people out there who be able to improve this in ways I can't, or see opportunities for improvement that I can't even imagine. If you want to contribute, bring it on! Send me a pull request.