From b093175b78c6f7d3374a4c55f84eedcf4d80778f Mon Sep 17 00:00:00 2001 From: Artem Leshchev Date: Mon, 16 Oct 2023 11:06:14 +0200 Subject: [PATCH] Fix routing keys --- .../Services/RabbitMqConsumerInitializer.cs | 6 ++++++ .../Settings/RabbitMqConsumerSettings.cs | 2 +- src/__SolutionItems/CommonAssemblyInfo.cs | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Framework.RabbitMq.Consumer/Services/RabbitMqConsumerInitializer.cs b/src/Framework.RabbitMq.Consumer/Services/RabbitMqConsumerInitializer.cs index 1eb9962e4..6ee44cb0b 100644 --- a/src/Framework.RabbitMq.Consumer/Services/RabbitMqConsumerInitializer.cs +++ b/src/Framework.RabbitMq.Consumer/Services/RabbitMqConsumerInitializer.cs @@ -16,6 +16,12 @@ public void Initialize(IModel model) model.ExchangeDeclare(consumerSettings.Exchange, ExchangeType.Topic, true); model.QueueDeclare(consumerSettings.Queue, true, false, false, null); + if (consumerSettings.RoutingKeys.Length == 0) + { + model.QueueBind(consumerSettings.Queue, consumerSettings.Exchange, "#"); + return; + } + foreach (var routingKey in consumerSettings.RoutingKeys) model.QueueBind(consumerSettings.Queue, consumerSettings.Exchange, routingKey); } diff --git a/src/Framework.RabbitMq.Consumer/Settings/RabbitMqConsumerSettings.cs b/src/Framework.RabbitMq.Consumer/Settings/RabbitMqConsumerSettings.cs index 6d951bb97..3ae0c76fb 100644 --- a/src/Framework.RabbitMq.Consumer/Settings/RabbitMqConsumerSettings.cs +++ b/src/Framework.RabbitMq.Consumer/Settings/RabbitMqConsumerSettings.cs @@ -14,5 +14,5 @@ public class RabbitMqConsumerSettings public string Queue { get; set; } = default!; - public string[] RoutingKeys { get; set; } = { "#" }; + public string[] RoutingKeys { get; set; } = Array.Empty(); } diff --git a/src/__SolutionItems/CommonAssemblyInfo.cs b/src/__SolutionItems/CommonAssemblyInfo.cs index c57b82fe9..9a4fad7c2 100644 --- a/src/__SolutionItems/CommonAssemblyInfo.cs +++ b/src/__SolutionItems/CommonAssemblyInfo.cs @@ -4,9 +4,9 @@ [assembly: AssemblyCompany("Luxoft")] [assembly: AssemblyCopyright("Copyright © Luxoft 2009-2023")] -[assembly: AssemblyVersion("19.1.0.0")] -[assembly: AssemblyFileVersion("19.1.0.0")] -[assembly: AssemblyInformationalVersion("19.1.0.0")] +[assembly: AssemblyVersion("19.1.1.0")] +[assembly: AssemblyFileVersion("19.1.1.0")] +[assembly: AssemblyInformationalVersion("19.1.1.0")] #if DEBUG [assembly: AssemblyConfiguration("Debug")]