Ejemplo n.º 1
0
        async Task Attempt(RetryConsumeContext context, IPipe <ConsumeContext> next)
        {
            context.ClearPendingFaults();

            TimeSpan delay;

            try
            {
                await next.Send(context).ConfigureAwait(false);

                return;
            }
            catch (Exception ex)
            {
                if (!_retryPolicy.CanRetry(ex))
                {
                    context.NotifyPendingFaults();
                    throw;
                }

                // by not adding the retry payload until the exception occurs, the deepest retry filter
                // is the one to set the actual retry context with the deepest configured policy
                IRetryContext retryContext = context.GetOrAddPayload(() => _retryPolicy.GetRetryContext());
                if (!retryContext.CanRetry(ex, out delay))
                {
                    context.NotifyPendingFaults();
                    throw;
                }
            }

            await Task.Delay(delay).ConfigureAwait(false);

            await Attempt(context, next).ConfigureAwait(false);
        }
 public Task RetryFaulted(Exception exception)
 {
     return(Task.WhenAll(_context.NotifyPendingFaults(), _policyContext.RetryFaulted(exception)));
 }
        public async Task RetryFaulted(Exception exception)
        {
            await _retryContext.RetryFaulted(exception).ConfigureAwait(false);

            await _context.NotifyPendingFaults().ConfigureAwait(false);
        }