private async Task Handle(EventData eventData) { try { HConsole.WriteLine(this, $"Handle event, correlation:{eventData.Message.CorrelationId} queue:{eventData.PartitionId}"); await eventData.Subscription.HandleAsync(eventData.Message).CfAwait(); } catch (Exception e) { HConsole.WriteLine(this, "Handler has thrown."); Interlocked.Increment(ref _exceptionCount); var args = new DistributedEventExceptionEventArgs(e, eventData.Message); var correlationId = eventData.Message.CorrelationId; try { HandlerError?.Invoke(this, args); } catch (Exception ee) { var ae = new AggregateException(e, ee); _logger.LogError(ae, $"An event handler [{correlationId}] has thrown an unhandled exception. " + "In addition, the error handler has also thrown an exception."); } if (!args.Handled) { Interlocked.Increment(ref _unhandledExceptionCount); _logger.LogError(e, $"An event handler [{correlationId}] has thrown an unhandled exception."); } } }