コード例 #1
0
        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));
            }
        }
コード例 #2
0
 /// <inheritdoc/>
 protected override PartitionedFilterResponse CreateResponseFromFailure(ProcessorFailure failure)
 => new PartitionedFilterResponse
 {
     Failure = failure,
 };
コード例 #3
0
 protected override Response CreateResponseFromFailure(ProcessorFailure failure) => new Response
 {
      Failure = failure
 };
コード例 #4
0
 /// <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);
コード例 #5
0
 /// <inheritdoc/>
 protected override EventHandlerResponse CreateResponseFromFailure(ProcessorFailure failure)
 => new EventHandlerResponse
 {
     Failure = failure,
 };