Skip to content

Commit

Permalink
[ServiceBus] Avoid reporting OperationCanceledException in message pu…
Browse files Browse the repository at this point in the history
…mp (#7935)

When the pump is being shut down, Cancel is called on pumpCancellationToken, which eventually throws OperationCanceledException while waiting on the maxConcurrentCallsSemaphoreSlim.
Since it is a genuine situation, avoid reporting it.

Fixes #6410
  • Loading branch information
nemakam authored Oct 12, 2019
1 parent 8698cf6 commit a72b04f
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ async Task MessagePumpTaskAsync()
});
}
}
catch (OperationCanceledException) when (pumpCancellationToken.IsCancellationRequested)
{
// Ignore as we are stopping the pump
}
catch (ObjectDisposedException) when (pumpCancellationToken.IsCancellationRequested)
{
// Ignore as we are stopping the pump
}
catch (Exception exception)
{
// Not reporting an ObjectDisposedException as we're stopping the pump
if (!(exception is ObjectDisposedException && this.pumpCancellationToken.IsCancellationRequested))
{
MessagingEventSource.Log.MessageReceivePumpTaskException(this.messageReceiver.ClientId, string.Empty, exception);
await this.RaiseExceptionReceived(exception, ExceptionReceivedEventArgsAction.Receive).ConfigureAwait(false);
}
MessagingEventSource.Log.MessageReceivePumpTaskException(this.messageReceiver.ClientId, string.Empty, exception);
await this.RaiseExceptionReceived(exception, ExceptionReceivedEventArgsAction.Receive).ConfigureAwait(false);
}
finally
{
Expand Down

0 comments on commit a72b04f

Please sign in to comment.