Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ppossanzini committed Dec 17, 2024
1 parent 4ed416d commit 4ded829
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Arbitrer.RabbitMQ/RequestsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,32 @@ private async void Watchguard()
await Task.Delay(TimeSpan.FromMinutes(2));
while (true)
{
var toremove = new HashSet<Type>();
var torebind = new HashSet<Type>();

foreach (var k in _consumers)
{
if (!k.Value.IsRunning)
{
_logger.LogError($"Stopping consumer for {k.Key}: The consumer is stopped for {k.Value.ShutdownReason?.Exception?.Message ?? "unknown reason"}");
toremove.Add(k.Key);
torebind.Add(k.Key);
}
}

foreach (var t in toremove)
foreach (var t in torebind)
{
if (_consumers.ContainsKey(t))
_consumers.Remove(t);
}

await CheckRequestsConsumers(CancellationToken.None);
if (torebind.Any())
{
await CheckConnection(CancellationToken.None);
await CheckRequestsConsumers(CancellationToken.None);
await ValidateConnectionQos(CancellationToken.None);
}


toremove.Clear();
torebind.Clear();
await Task.Delay(TimeSpan.FromMinutes(2));
}
}
Expand Down

0 comments on commit 4ded829

Please sign in to comment.