/// <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)); }
/// <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)); }