This commit is contained in:
xiaolipro 2025-02-06 17:12:43 +08:00
parent 256ce4d543
commit e51f5509ea
2 changed files with 9 additions and 1 deletions

View File

@ -18,7 +18,7 @@
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
<PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.2.2.1"/>
<PackageReference Include="Fake.AspNetCore" Version="8.0.0-preview.5" />
<PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0-preview.5" />
<PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0-preview.6" />
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0-preview.5" />
<PackageReference Include="FreeRedis" Version="1.3.6" />
</ItemGroup>

View File

@ -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,