Search in sources :

Example 1 with AlwaysRetryPolicy

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

the class StatefulRetryOperationsInterceptorTests method testDefaultInterceptorAlwaysRetry.

@Test
public void testDefaultInterceptorAlwaysRetry() throws Exception {
    retryTemplate.setRetryPolicy(new AlwaysRetryPolicy());
    interceptor.setRetryOperations(retryTemplate);
    ((Advised) service).addAdvice(interceptor);
    try {
        service.service("foo");
        fail("Expected Exception.");
    } catch (Exception e) {
        String message = e.getMessage();
        assertTrue("Wrong message: " + message, message.startsWith("Not enough calls"));
    }
    assertEquals(1, count);
}
Also used : Advised(cn.taketoday.aop.framework.Advised) AlwaysRetryPolicy(cn.taketoday.retry.policy.AlwaysRetryPolicy) ExhaustedRetryException(cn.taketoday.retry.ExhaustedRetryException) Test(org.junit.jupiter.api.Test)

Example 2 with AlwaysRetryPolicy

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

the class RetryTemplateBuilder method infiniteRetry.

/**
 * Allows infinite retry, do not limit attempts by number or time.
 * <p>
 * Invocation of this method does not discard default exception classification rule,
 * that is "retry only on {@link Exception} and it's subclasses".
 *
 * @return this
 * @see TimeoutRetryPolicy
 */
public RetryTemplateBuilder infiniteRetry() {
    Assert.isNull(this.baseRetryPolicy, "You have already selected another retry policy");
    this.baseRetryPolicy = new AlwaysRetryPolicy();
    return this;
}
Also used : AlwaysRetryPolicy(cn.taketoday.retry.policy.AlwaysRetryPolicy)

Example 3 with AlwaysRetryPolicy

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

the class StatefulRetryOperationsInterceptorTests method testDefaultInterceptorAlwaysRetry.

@Test
public void testDefaultInterceptorAlwaysRetry() throws Exception {
    retryTemplate.setRetryPolicy(new AlwaysRetryPolicy());
    interceptor.setRetryOperations(retryTemplate);
    ((Advised) service).addAdvice(interceptor);
    try {
        service.service("foo");
        fail("Expected Exception.");
    } catch (Exception e) {
        String message = e.getMessage();
        assertTrue("Wrong message: " + message, message.startsWith("Not enough calls"));
    }
    assertEquals(1, count);
}
Also used : Advised(cn.taketoday.aop.framework.Advised) AlwaysRetryPolicy(cn.taketoday.retry.policy.AlwaysRetryPolicy) ExhaustedRetryException(cn.taketoday.retry.ExhaustedRetryException) Test(org.junit.jupiter.api.Test)

Example 4 with AlwaysRetryPolicy

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

the class RetryTemplateBuilder method infiniteRetry.

/**
 * Allows infinite retry, do not limit attempts by number or time.
 * <p>
 * Invocation of this method does not discard default exception classification rule,
 * that is "retry only on {@link Exception} and it's subclasses".
 *
 * @return this
 * @see TimeoutRetryPolicy
 */
public RetryTemplateBuilder infiniteRetry() {
    Assert.isNull(this.baseRetryPolicy, "You have already selected another retry policy");
    this.baseRetryPolicy = new AlwaysRetryPolicy();
    return this;
}
Also used : AlwaysRetryPolicy(cn.taketoday.retry.policy.AlwaysRetryPolicy)

Aggregations

AlwaysRetryPolicy (cn.taketoday.retry.policy.AlwaysRetryPolicy)4 Advised (cn.taketoday.aop.framework.Advised)2 ExhaustedRetryException (cn.taketoday.retry.ExhaustedRetryException)2 Test (org.junit.jupiter.api.Test)2