Beispiel #1
0
            public object Recover(IRetryContext context)
            {
                if (!ShouldRequeue((MessagingException)context.LastException))
                {
                    return(_recoveryCallback.Recover(context));
                }

                throw (MessagingException)context.LastException;
            }
Beispiel #2
0
        /// <summary>Actions to take after final attempt has failed. If there is state clean
        /// up the cache. If there is a recovery callback, execute that and return
        /// its result. Otherwise throw an exception.</summary>
        /// <param name="recoveryCallback">The callback for recovery (might be null).</param>
        /// <param name="context">The current retry context.</param>
        /// <param name="state">The state.</param>
        /// <returns>The T.</returns>
        /// <typeparam name="T">Type T.</typeparam>
        protected T HandleRetryExhausted <T>(IRecoveryCallback <T> recoveryCallback, IRetryContext context, IRetryState state)
        {
            if (state != null)
            {
                this.retryContextCache.Remove(state.GetKey());
            }

            if (recoveryCallback != null)
            {
                return(recoveryCallback.Recover(context));
            }

            if (state != null)
            {
                Logger.Debug(m => m("Retry exhausted after last attempt with no recovery path."));
                throw new ExhaustedRetryException("Retry exhausted after last attempt with no recovery path", context.LastException);
            }

            throw WrapIfNecessary(context.LastException);
        }