use of cn.taketoday.retry.policy.BinaryExceptionClassifierRetryPolicy in project today-infrastructure by TAKETODAY.
the class RetryTemplateBuilder method build.
/* ---------------- Building -------------- */
/**
* Finish configuration and build resulting {@link RetryTemplate}. For default
* behaviour and concurrency note see class-level doc of {@link RetryTemplateBuilder}.
* The {@code retryPolicy} of the returned {@link RetryTemplate} is always an instance
* of {@link CompositeRetryPolicy}, that consists of one base policy, and of
* {@link BinaryExceptionClassifierRetryPolicy}. The motivation is: whatever base
* policy we use, exception classification is extremely recommended.
*
* @return new instance of {@link RetryTemplate}
*/
public RetryTemplate build() {
RetryTemplate retryTemplate = new RetryTemplate();
// Exception classifier
BinaryExceptionClassifier exceptionClassifier = classifierBuilder != null ? classifierBuilder.build() : BinaryExceptionClassifier.defaultClassifier();
if (this.baseRetryPolicy == null) {
this.baseRetryPolicy = new MaxAttemptsRetryPolicy();
}
CompositeRetryPolicy finalPolicy = new CompositeRetryPolicy();
finalPolicy.setPolicies(new RetryPolicy[] { baseRetryPolicy, new BinaryExceptionClassifierRetryPolicy(exceptionClassifier) });
retryTemplate.setRetryPolicy(finalPolicy);
if (this.backOffPolicy == null) {
this.backOffPolicy = new NoBackOffPolicy();
}
retryTemplate.setBackOffPolicy(this.backOffPolicy);
if (this.listeners != null) {
retryTemplate.setListeners(this.listeners.toArray(new RetryListener[0]));
}
return retryTemplate;
}
use of cn.taketoday.retry.policy.BinaryExceptionClassifierRetryPolicy in project today-framework by TAKETODAY.
the class RetryTemplateBuilder method build.
/* ---------------- Building -------------- */
/**
* Finish configuration and build resulting {@link RetryTemplate}. For default
* behaviour and concurrency note see class-level doc of {@link RetryTemplateBuilder}.
* The {@code retryPolicy} of the returned {@link RetryTemplate} is always an instance
* of {@link CompositeRetryPolicy}, that consists of one base policy, and of
* {@link BinaryExceptionClassifierRetryPolicy}. The motivation is: whatever base
* policy we use, exception classification is extremely recommended.
*
* @return new instance of {@link RetryTemplate}
*/
public RetryTemplate build() {
RetryTemplate retryTemplate = new RetryTemplate();
// Exception classifier
BinaryExceptionClassifier exceptionClassifier = classifierBuilder != null ? classifierBuilder.build() : BinaryExceptionClassifier.defaultClassifier();
if (this.baseRetryPolicy == null) {
this.baseRetryPolicy = new MaxAttemptsRetryPolicy();
}
CompositeRetryPolicy finalPolicy = new CompositeRetryPolicy();
finalPolicy.setPolicies(new RetryPolicy[] { baseRetryPolicy, new BinaryExceptionClassifierRetryPolicy(exceptionClassifier) });
retryTemplate.setRetryPolicy(finalPolicy);
if (this.backOffPolicy == null) {
this.backOffPolicy = new NoBackOffPolicy();
}
retryTemplate.setBackOffPolicy(this.backOffPolicy);
if (this.listeners != null) {
retryTemplate.setListeners(this.listeners.toArray(new RetryListener[0]));
}
return retryTemplate;
}
Aggregations