Exemplo n.º 1
0
        /// <summary>
        /// Creates and returns an "primary key violation" command Retry Policy.
        /// </summary>
        /// <param name="ignorableErrorNumbers">Errors to ignore if they occur after first retry</param>
        /// <remarks>
        /// The RetryOccured event is wired to raise an RaiseAmbientRetryMessage message for a command retry.
        /// The IgnoreErrorOccurred event is wired to raise an RaiseAmbientIgnoreMessage message for ignore.
        /// </remarks>
        /// <returns>An instance of <see cref="RetryPolicy"/> class.</returns>
        internal static RetryPolicy CreatePrimaryKeyCommandRetryPolicy()
        {
            RetryPolicy.SqlAzureTemporaryAndIgnorableErrorDetectionStrategy errorDetectionStrategy =
                new RetryPolicy.SqlAzureTemporaryAndIgnorableErrorDetectionStrategy(SqlErrorNumbers.PrimaryKeyViolationErrorNumber);

            RetryPolicy policy = new RetryPolicy.ExponentialDelayRetryPolicy(
                errorDetectionStrategy,
                RetryPolicyDefaults.DefaulSchemaRetryCount,
                RetryPolicyDefaults.DefaultBackoffIntervalFactor,
                RetryPolicyDefaults.DefaultSchemaMinInterval,
                RetryPolicyDefaults.DefaultMaxRetryInterval);

            policy.FastFirstRetry       = true;
            policy.RetryOccurred       += CommandFailureRetry;
            policy.IgnoreErrorOccurred += CommandFailureIgnore;

            return(policy);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates and returns a Retry Policy for database creation operations.
        /// </summary>
        /// <param name="ignorableErrorNumbers">Errors to ignore if they occur after first retry</param>
        /// <remarks>
        /// The RetryOccured event is wired to raise an RaiseAmbientRetryMessage message for a command retry.
        /// The IgnoreErrorOccurred event is wired to raise an RaiseAmbientIgnoreMessage message for ignore.
        /// </remarks>
        /// <returns>An instance of <see cref="RetryPolicy"/> class.</returns>
        internal static RetryPolicy CreateDatabaseCommandRetryPolicy(params int[] ignorableErrorNumbers)
        {
            RetryPolicy.SqlAzureTemporaryAndIgnorableErrorDetectionStrategy errorDetectionStrategy =
                new RetryPolicy.SqlAzureTemporaryAndIgnorableErrorDetectionStrategy(ignorableErrorNumbers);

            // 30, 60, 60, 60, 60 second retries
            RetryPolicy policy = new RetryPolicy.ExponentialDelayRetryPolicy(
                errorDetectionStrategy,
                RetryPolicyDefaults.DefaultCreateDatabaseRetryCount /* maxRetryCount */,
                RetryPolicyDefaults.DefaultBackoffIntervalFactor,
                TimeSpan.FromSeconds(30) /* minInterval */,
                TimeSpan.FromSeconds(60) /* maxInterval */);

            policy.FastFirstRetry       = false;
            policy.RetryOccurred       += CreateDatabaseCommandFailureRetry;
            policy.IgnoreErrorOccurred += CreateDatabaseCommandFailureIgnore;

            return(policy);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates and returns an "ignoreable" command Retry Policy.
        /// </summary>
        /// <param name="ignorableErrorNumbers">Errors to ignore if they occur after first retry</param>
        /// <remarks>
        /// The RetryOccured event is wired to raise an RaiseAmbientRetryMessage message for a command retry.
        /// The IgnoreErrorOccurred event is wired to raise an RaiseAmbientIgnoreMessage message for ignore.
        /// </remarks>
        /// <returns>An instance of <see cref="RetryPolicy"/> class.</returns>
        internal static RetryPolicy CreateElementCommandRetryPolicy(params int[] ignorableErrorNumbers)
        {
            Debug.Assert(ignorableErrorNumbers != null);

            RetryPolicy.SqlAzureTemporaryAndIgnorableErrorDetectionStrategy errorDetectionStrategy =
                new RetryPolicy.SqlAzureTemporaryAndIgnorableErrorDetectionStrategy(ignorableErrorNumbers);

            RetryPolicy policy = new RetryPolicy.ExponentialDelayRetryPolicy(
                errorDetectionStrategy,
                RetryPolicyDefaults.DefaulSchemaRetryCount,
                RetryPolicyDefaults.DefaultBackoffIntervalFactor,
                RetryPolicyDefaults.DefaultSchemaMinInterval,
                RetryPolicyDefaults.DefaultMaxRetryInterval);

            policy.FastFirstRetry       = false;
            policy.RetryOccurred       += ElementCommandFailureRetry;
            policy.IgnoreErrorOccurred += ElementCommandFailureIgnore;

            return(policy);
        }