async Task <TResponse> CatchingHandle(TRequest request, CancellationToken cancellationToken) { RetryProcessingState retryState = null; try { retryState = GetRetryProcessingState(request); return(await Handle(request, cancellationToken).ConfigureAwait(false)); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } var failure = new ProcessorFailure { Reason = ex.Message, Retry = true, RetryTimeout = CalculateRetryTimeout(retryState), }; _logger.Warning(ex, "Processing in {Kind} {Id} failed. Will retry in {RetryTimeout} seconds.", Kind, Identifier, failure.RetryTimeout.Seconds); return(CreateResponseFromFailure(failure)); } }
/// <inheritdoc/> protected override PartitionedFilterResponse CreateResponseFromFailure(ProcessorFailure failure) => new PartitionedFilterResponse { Failure = failure, };
protected override Response CreateResponseFromFailure(ProcessorFailure failure) => new Response { Failure = failure };
/// <summary> /// The method that will be called to create a response to the Runtime in the case when handling of a request fails. /// The provided failure will have the exception message and retry properties set based on the retry strategy. /// </summary> /// <param name="failure">A <see cref="ProcessorFailure"/> populated with the failure reason and retry strategy.</param> /// <returns>A <typeparamref name="TResponse"/> to send back to the Runtime.</returns> protected abstract TResponse CreateResponseFromFailure(ProcessorFailure failure);
/// <inheritdoc/> protected override EventHandlerResponse CreateResponseFromFailure(ProcessorFailure failure) => new EventHandlerResponse { Failure = failure, };