From e51f5509ea7e8c71a9fc9f461a9af5dd388f4938 Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Thu, 6 Feb 2025 17:12:43 +0800 Subject: [PATCH] 1 --- .../InterfaceForward.Application.csproj | 2 +- src/InterfaceForward.Application/Rabbit/RabbitClient.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/InterfaceForward.Application/InterfaceForward.Application.csproj b/src/InterfaceForward.Application/InterfaceForward.Application.csproj index e8d9545..be834f3 100644 --- a/src/InterfaceForward.Application/InterfaceForward.Application.csproj +++ b/src/InterfaceForward.Application/InterfaceForward.Application.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/InterfaceForward.Application/Rabbit/RabbitClient.cs b/src/InterfaceForward.Application/Rabbit/RabbitClient.cs index a1cf447..14574ba 100644 --- a/src/InterfaceForward.Application/Rabbit/RabbitClient.cs +++ b/src/InterfaceForward.Application/Rabbit/RabbitClient.cs @@ -14,6 +14,9 @@ public class RabbitClient( public void Subscribe(ConsumeOptions consumeOptions) { using var channelAccessor = channelPool.Acquire(consumeOptions.Queue); + + if (!channelAccessor.IsNew) return; + var channel = channelAccessor.Channel; consumeOptions.Declaration.Invoke(channel); @@ -35,6 +38,11 @@ public class RabbitClient( } } }; + + channel.CallbackException += (sender, args) => + { + logger.LogError(args.Exception, "RabbitMQ channel exception"); + }; channel.BasicConsume(queue: consumeOptions.Queue, autoAck: false,