Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,36 @@ protected async Task startNewChannel()

Channel.CallbackExceptionAsync += (sender, args) =>
{
Logger.LogError(args.Exception, "Callback error in Rabbit Mq agent");
Logger.LogError(args.Exception, "Callback error in Rabbit Mq agent. Attempting to restart the channel");

// Try to restart the connection
#pragma warning disable VSTHRD110
Task.Run(async () =>
#pragma warning restore VSTHRD110
{
await Locker.WaitAsync();
try
{
_monitor.Remove(this);
try
{
await teardownChannel();
}
catch (Exception e)
{
Logger.LogError(e, "Error when trying to tear down a blocked channel");
}

Channel = null;
await EnsureInitiated();
Logger.LogInformation("Restarted the Rabbit MQ channel");
}
finally
{
Locker.Release();
}
});

return Task.CompletedTask;
};

Expand Down
Loading