From 7fcb5121aeda73c72fc78cceb5f012f73bfbcc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 19 Feb 2021 18:15:10 +0300 Subject: [PATCH] Should check the result of QueueBindCommands.TryPeek. --- .../Abp/RabbitMQ/RabbitMqMessageConsumer.cs | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs index f757efab64..894f68d097 100644 --- a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs +++ b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs @@ -90,29 +90,30 @@ namespace Volo.Abp.RabbitMQ lock (ChannelSendSyncLock) { - QueueBindCommands.TryPeek(out var command); - - switch (command.Type) + if (QueueBindCommands.TryPeek(out var command)) { - case QueueBindType.Bind: - Channel.QueueBind( - queue: Queue.QueueName, - exchange: Exchange.ExchangeName, - routingKey: command.RoutingKey - ); - break; - case QueueBindType.Unbind: - Channel.QueueUnbind( - queue: Queue.QueueName, - exchange: Exchange.ExchangeName, - routingKey: command.RoutingKey - ); - break; - default: - throw new AbpException($"Unknown {nameof(QueueBindType)}: {command.Type}"); + switch (command.Type) + { + case QueueBindType.Bind: + Channel.QueueBind( + queue: Queue.QueueName, + exchange: Exchange.ExchangeName, + routingKey: command.RoutingKey + ); + break; + case QueueBindType.Unbind: + Channel.QueueUnbind( + queue: Queue.QueueName, + exchange: Exchange.ExchangeName, + routingKey: command.RoutingKey + ); + break; + default: + throw new AbpException($"Unknown {nameof(QueueBindType)}: {command.Type}"); + } + + QueueBindCommands.TryDequeue(out command); } - - QueueBindCommands.TryDequeue(out command); } } }