ImmediateRetry() public static method

Creates an immediate retry recoverability action.
public static ImmediateRetry ( ) : ImmediateRetry
return ImmediateRetry
コード例 #1
0
        /// <summary>
        /// Invokes the default recovery policy.
        /// </summary>
        /// <param name="config">The recoverability configuration.</param>
        /// <param name="errorContext">The error context.</param>
        /// <returns>The recoverability action.</returns>
        public static RecoverabilityAction Invoke(RecoverabilityConfig config, ErrorContext errorContext)
        {
            Guard.AgainstNull(nameof(errorContext), errorContext);
            Guard.AgainstNull(nameof(config), config);
            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (var unrecoverableExceptionType in config.Failed.UnrecoverableExceptionTypes)
            {
                if (unrecoverableExceptionType.IsInstanceOfType(errorContext.Exception))
                {
                    return(RecoverabilityAction.MoveToError(config.Failed.ErrorQueue));
                }
            }

            if (errorContext.ImmediateProcessingFailures <= config.Immediate.MaxNumberOfRetries)
            {
                return(RecoverabilityAction.ImmediateRetry());
            }

            TimeSpan delay;

            if (TryGetDelay(errorContext.Message, errorContext.DelayedDeliveriesPerformed, config.Delayed, out delay))
            {
                return(RecoverabilityAction.DelayedRetry(delay));
            }

            return(RecoverabilityAction.MoveToError(config.Failed.ErrorQueue));
        }
コード例 #2
0
        /// <summary>
        /// Invokes the default recovery policy.
        /// </summary>
        /// <param name="config">The recoverability configuration.</param>
        /// <param name="errorContext">The error context.</param>
        /// <returns>The recoverability action.</returns>
        public static RecoverabilityAction Invoke(RecoverabilityConfig config, ErrorContext errorContext)
        {
            if (errorContext.Exception is MessageDeserializationException)
            {
                return(RecoverabilityAction.MoveToError(config.Failed.ErrorQueue));
            }

            if (errorContext.ImmediateProcessingFailures <= config.Immediate.MaxNumberOfRetries)
            {
                return(RecoverabilityAction.ImmediateRetry());
            }

            TimeSpan delay;

            if (TryGetDelay(errorContext.Message, errorContext.DelayedDeliveriesPerformed, config.Delayed, out delay))
            {
                return(RecoverabilityAction.DelayedRetry(delay));
            }

            return(RecoverabilityAction.MoveToError(config.Failed.ErrorQueue));
        }