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);
}
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;
}
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);
}
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;
}
Aggregations