From b238cbb0204d10b6ec34a3bb33681c263059d338 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Tue, 9 Mar 2021 17:46:22 +0800 Subject: [PATCH] Compatible with queues that have been created. #772 --- src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs | 4 ++-- src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs index a701e2c..46b7a3e 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs @@ -82,9 +82,9 @@ namespace DotNetCore.CAP public class QueueArgumentsOptions { /// - /// Gets or sets queue mode by supplying the 'x-queue-mode' declaration argument with a string specifying the desired mode. Default 'default' + /// Gets or sets queue mode by supplying the 'x-queue-mode' declaration argument with a string specifying the desired mode. /// - public string QueueMode { get; set; } = "default"; + public string QueueMode { get; set; } /// /// Gets or sets queue message automatic deletion time (in milliseconds) "x-message-ttl", Default 864000000 ms (10 days). diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs index 8f0e6a2..522132a 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs @@ -116,9 +116,14 @@ namespace DotNetCore.CAP.RabbitMQ var arguments = new Dictionary { - {"x-queue-mode", _rabbitMQOptions.QueueArguments.QueueMode}, {"x-message-ttl", _rabbitMQOptions.QueueArguments.MessageTTL} }; + + if (!string.IsNullOrEmpty(_rabbitMQOptions.QueueArguments.QueueMode)) + { + arguments.Add("x-queue-mode", _rabbitMQOptions.QueueArguments.QueueMode); + } + _channel.QueueDeclare(_queueName, durable: true, exclusive: false, autoDelete: false, arguments: arguments); } }