fix errors of Degraded Operations Visibility

This commit is contained in:
voltsrage
2026-06-24 00:46:27 +08:00
parent 4399996448
commit 2e80700bf0
7 changed files with 177 additions and 40 deletions
@@ -0,0 +1,38 @@
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
using RabbitMQ.Client.Exceptions;
public static class RabbitMqTestHelper
{
public static void PurgeNotificationQueues(IOptions<RabbitMqOptions> opts)
{
var o = opts.Value;
var factory = new ConnectionFactory
{
HostName = o.Host,
Port = o.Port,
UserName = o.Username,
Password = o.Password,
};
using var connection = factory.CreateConnection("test-queue-purge");
using var channel = connection.CreateModel();
foreach (var queue in new[]
{
"alerts.paging.queue",
"alerts.paging.dlq",
"alerts.escalation.queue",
})
{
try
{
channel.QueuePurge(queue);
}
catch (OperationInterruptedException)
{
// Queue may not exist yet on a cold broker.
}
}
}
}