Search in sources :

Example 1 with TimeoutRetryPolicy

use of cn.taketoday.retry.policy.TimeoutRetryPolicy in project today-framework by TAKETODAY.

the class RetryTemplateBuilder method withinMillis.

/**
 * Allows retry if there is no more than {@code timeout} millis since first attempt.
 * <p>
 * Invocation of this method does not discard default exception classification rule,
 * that is "retry only on {@link Exception} and it's subclasses".
 *
 * @param timeout whole execution timeout in milliseconds
 * @return this
 * @see TimeoutRetryPolicy
 */
public RetryTemplateBuilder withinMillis(long timeout) {
    Assert.isTrue(timeout > 0, "Timeout should be positive");
    Assert.isNull(this.baseRetryPolicy, "You have already selected another retry policy");
    TimeoutRetryPolicy timeoutRetryPolicy = new TimeoutRetryPolicy();
    timeoutRetryPolicy.setTimeout(timeout);
    this.baseRetryPolicy = timeoutRetryPolicy;
    return this;
}
Also used : TimeoutRetryPolicy(cn.taketoday.retry.policy.TimeoutRetryPolicy)

Example 2 with TimeoutRetryPolicy

use of cn.taketoday.retry.policy.TimeoutRetryPolicy in project today-infrastructure by TAKETODAY.

the class RetryTemplateBuilder method withinMillis.

/**
 * Allows retry if there is no more than {@code timeout} millis since first attempt.
 * <p>
 * Invocation of this method does not discard default exception classification rule,
 * that is "retry only on {@link Exception} and it's subclasses".
 *
 * @param timeout whole execution timeout in milliseconds
 * @return this
 * @see TimeoutRetryPolicy
 */
public RetryTemplateBuilder withinMillis(long timeout) {
    Assert.isTrue(timeout > 0, "Timeout should be positive");
    Assert.isNull(this.baseRetryPolicy, "You have already selected another retry policy");
    TimeoutRetryPolicy timeoutRetryPolicy = new TimeoutRetryPolicy();
    timeoutRetryPolicy.setTimeout(timeout);
    this.baseRetryPolicy = timeoutRetryPolicy;
    return this;
}
Also used : TimeoutRetryPolicy(cn.taketoday.retry.policy.TimeoutRetryPolicy)

Aggregations

TimeoutRetryPolicy (cn.taketoday.retry.policy.TimeoutRetryPolicy)2