Java Code Examples for org.springframework.retry.backoff.BackOffPolicy

The following examples show how to use org.springframework.retry.backoff.BackOffPolicy. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private RetryTemplate createRetryTemplate(String serviceName, HttpRequest request,
		LoadBalancedRetryPolicy retryPolicy) {
	RetryTemplate template = new RetryTemplate();
	BackOffPolicy backOffPolicy = this.lbRetryFactory
			.createBackOffPolicy(serviceName);
	template.setBackOffPolicy(
			backOffPolicy == null ? new NoBackOffPolicy() : backOffPolicy);
	template.setThrowLastExceptionOnExhausted(true);
	RetryListener[] retryListeners = this.lbRetryFactory
			.createRetryListeners(serviceName);
	if (retryListeners != null && retryListeners.length != 0) {
		template.setListeners(retryListeners);
	}
	template.setRetryPolicy(!this.lbProperties.isEnabled() || retryPolicy == null
			? new NeverRetryPolicy() : new InterceptorRetryPolicy(request,
					retryPolicy, this.loadBalancer, serviceName));
	return template;
}
 
Example 2
@Override
public BackOffPolicy createBackOffPolicy(String service) {
	if (this.backOffPolicy == null) {
		return new NoBackOffPolicy();
	}
	else {
		return this.backOffPolicy;
	}
}
 
Example 3
Source Project: tutorials   Source File: ExponentialBackoffRetryFactory.java    License: MIT License 5 votes vote down vote up
@Override
public BackOffPolicy createBackOffPolicy(String service) {
    ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy();
    exponentialBackOffPolicy.setInitialInterval(1000);
    exponentialBackOffPolicy.setMultiplier(2);
    exponentialBackOffPolicy.setMaxInterval(10000);
    return exponentialBackOffPolicy;
}
 
Example 4
Source Project: tutorials   Source File: ExponentialRandomBackoffRetryFactory.java    License: MIT License 5 votes vote down vote up
@Override
public BackOffPolicy createBackOffPolicy(String service) {
    ExponentialRandomBackOffPolicy exponentialRandomBackOffPolicy = new ExponentialRandomBackOffPolicy();
    exponentialRandomBackOffPolicy.setInitialInterval(1000);
    exponentialRandomBackOffPolicy.setMultiplier(2);
    exponentialRandomBackOffPolicy.setMaxInterval(10000);
    return exponentialRandomBackOffPolicy;
}
 
Example 5
BackOffPolicy getBackOffPolicy() {
	return backOffPolicy;
}
 
Example 6
void setBackOffPolicy(BackOffPolicy backOffPolicy) {
	this.backOffPolicy = backOffPolicy;
}
 
Example 7
MyLoadBalancedRetryFactory(LoadBalancedRetryPolicy loadBalancedRetryPolicy,
		BackOffPolicy backOffPolicy) {
	this(loadBalancedRetryPolicy);
	this.backOffPolicy = backOffPolicy;
}
 
Example 8
MyLoadBalancedRetryFactory(LoadBalancedRetryPolicy loadBalancedRetryPolicy,
		BackOffPolicy backOffPolicy, RetryListener[] retryListeners) {
	this(loadBalancedRetryPolicy, backOffPolicy);
	this.retryListeners = retryListeners;
}
 
Example 9
Source Project: tutorials   Source File: FixedBackoffRetryFactory.java    License: MIT License 4 votes vote down vote up
@Override
public BackOffPolicy createBackOffPolicy(String service) {
    FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
    fixedBackOffPolicy.setBackOffPeriod(2000);
    return fixedBackOffPolicy;
}
 
Example 10
/**
 * Creates a {@link BackOffPolicy} for a given service.
 * @param service The service to create the {@link BackOffPolicy} for.
 * @return The {@link BackOffPolicy}.
 */
default BackOffPolicy createBackOffPolicy(String service) {
	return new NoBackOffPolicy();
}