RecoverabilityAction MyCustomRetryPolicy(RecoverabilityConfig config, ErrorContext context) { // early decisions and return before custom policy is invoked // i.e. all unrecoverable exceptions should always go to customized error queue foreach (var exceptionType in config.Failed.UnrecoverableExceptionTypes) { if (exceptionType.IsInstanceOfType(context.Exception)) { return(RecoverabilityAction.MoveToError("customErrorQueue")); } } // If it does not make sense to have this message around anymore // it can be discarded with a reason. if (context.Exception is MyBusinessTimedOutException) { return(RecoverabilityAction.Discard("Business operation timed out.")); } // override delayed retry decision for custom exception // i.e. MyOtherBusinessException should do fixed backoff of 5 seconds if (context.Exception is MyOtherBusinessException && context.DelayedDeliveriesPerformed < config.Delayed.MaxNumberOfRetries) { return(RecoverabilityAction.DelayedRetry(TimeSpan.FromSeconds(5))); } // in all other cases No Immediate or Delayed Retries, go to default error queue return(RecoverabilityAction.MoveToError(config.Failed.ErrorQueue)); }
void Simple(EndpointConfiguration endpointConfiguration, IEndpointInstance endpoint, ILog log) { #region Callbacks-Recoverability endpointConfiguration.Recoverability().CustomPolicy((config, context) => { if (context.Exception is InvalidOperationException invalidOperationException && invalidOperationException.Message.StartsWith("No handlers could be found", StringComparison.OrdinalIgnoreCase)) { return(RecoverabilityAction.Discard("Callback no longer active")); } return(DefaultRecoverabilityPolicy.Invoke(config, context)); }); #endregion }
public static RecoverabilityAction MyCoronaServiceRetryPolicy(RecoverabilityConfig config, ErrorContext context) { var action = DefaultRecoverabilityPolicy.Invoke(config, context); if (!(action is DelayedRetry delayedRetryAction)) { return(action); } /* if (context.Exception is PatientNotExistExcption) * { * return RecoverabilityAction.MoveToError(config.Failed.ErrorQueue); * }*/ if (context.Exception is NullReferenceException) { return(RecoverabilityAction.Discard("Business operation timed out.")); } // Override default delivery delay. return(RecoverabilityAction.DelayedRetry(TimeSpan.FromMinutes(3))); }
public static RecoverabilityAction MyCustomRetryPolicy(RecoverabilityConfig config, ErrorContext context) { // early decisions and return before custom policy is invoked // i.e. all unrecoverable exceptions should always go to customized error queue foreach (var exceptionType in config.Failed.UnrecoverableExceptionTypes) { if (exceptionType.IsInstanceOfType(context.Exception)) { return(RecoverabilityAction.MoveToError("customErrorQueue")); } } // If it does not make sense to have this message around anymore // it can be discarded with a reason. if (context.Exception is MyBusinessTimedOutException) { return(RecoverabilityAction.Discard("Business operation timed out.")); } // in all other cases No Immediate or Delayed Retries, go to default error queue return(RecoverabilityAction.MoveToError(config.Failed.ErrorQueue)); }
protected override void Setup(FeatureConfigurationContext context) { context.AddSatelliteReceiver("QuorumQueueSatelliteReceiver", "QuorumQueueSatelliteReceiver", PushRuntimeSettings.Default, (_, __) => RecoverabilityAction.Discard(string.Empty), (_, __, ___) => Task.CompletedTask); }