From d26520ca84ff017d2f42d62af0d2e09b9cbb17f5 Mon Sep 17 00:00:00 2001 From: "vitalie.glinca" Date: Tue, 21 Nov 2023 15:21:56 +0200 Subject: [PATCH] Add tests --- .../messaging/transports/rabbitmq/index.md | 9 ++++++ .../Wolverine.RabbitMQ.Tests/Samples.cs | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/docs/guide/messaging/transports/rabbitmq/index.md b/docs/guide/messaging/transports/rabbitmq/index.md index baca5a491..10535d21c 100644 --- a/docs/guide/messaging/transports/rabbitmq/index.md +++ b/docs/guide/messaging/transports/rabbitmq/index.md @@ -54,6 +54,15 @@ return await Host.CreateDefaultBuilder(args) See the [Rabbit MQ .NET Client documentation](https://www.rabbitmq.com/dotnet-api-guide.html#connecting) for more information about configuring the `ConnectionFactory` to connect to Rabbit MQ. +## Disable Rabbit MQ Reply Queues +By default, Wolverine creates an in memory queue in the Rabbit MQ broker for each individual node that is used by Wolverine +for request/reply invocations (`IMessageBus.InvokeAsync()` when used remotely). Great, but if your process does not +have permissions with your Rabbit MQ broker to create queues, you may encounter errors. Not to worry, you can disable +that Wolverine system queue creation with: + +snippet: sample_disable_rabbit_mq_system_queue + +Of course, doing so means that you will not be able to do request/reply through Rabbit MQ with your Wolverine application. diff --git a/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/Samples.cs b/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/Samples.cs index c27f77e1f..4ff46e2ea 100644 --- a/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/Samples.cs +++ b/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/Samples.cs @@ -48,6 +48,36 @@ public static async Task listen_to_topics() #endregion } + public static async Task disable_system_queue() + { + #region sample_disable_rabbit_mq_system_queue + + using var host = await Host.CreateDefaultBuilder() + .UseWolverine(opts => + { + // *A* way to configure Rabbit MQ using their Uri schema + // documented here: https://www.rabbitmq.com/uri-spec.html + opts.UseRabbitMq(new Uri("amqp://localhost")) + + // Stop Wolverine from trying to create a reply queue + // for this node if your process does not have permission to + // do so against your Rabbit MQ broker + .DisableSystemRequestReplyQueueDeclaration(); + + + + // Set up a listener for a queue, but also + // fine-tune the queue characteristics if Wolverine + // will be governing the queue setup + opts.ListenToRabbitQueue("incoming2", q => + { + q.PurgeOnStartup = true; + q.TimeToLive(5.Minutes()); + }); + }).StartAsync(); + + #endregion + } public static async Task listen_to_queue() {