예제 #1
0
        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));
        }
예제 #2
0
        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
        }
예제 #3
0
        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)));
        }
예제 #4
0
    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);
 }