Search in sources :

Example 1 with NeverRetryPolicy

use of org.springframework.retry.policy.NeverRetryPolicy in project spring-cloud-netflix by spring-cloud.

the class RetryableRibbonLoadBalancingHttpClient method executeWithRetry.

private RibbonApacheHttpResponse executeWithRetry(RibbonApacheHttpRequest request, LoadBalancedRetryPolicy retryPolicy, RetryCallback<RibbonApacheHttpResponse, Exception> callback, RecoveryCallback<RibbonApacheHttpResponse> recoveryCallback) throws Exception {
    RetryTemplate retryTemplate = new RetryTemplate();
    boolean retryable = isRequestRetryable(request);
    retryTemplate.setRetryPolicy(retryPolicy == null || !retryable ? new NeverRetryPolicy() : new RetryPolicy(request, retryPolicy, this, this.getClientName()));
    BackOffPolicy backOffPolicy = loadBalancedRetryFactory.createBackOffPolicy(this.getClientName());
    retryTemplate.setBackOffPolicy(backOffPolicy == null ? new NoBackOffPolicy() : backOffPolicy);
    RetryListener[] retryListeners = this.loadBalancedRetryFactory.createRetryListeners(this.getClientName());
    if (retryListeners != null && retryListeners.length != 0) {
        retryTemplate.setListeners(retryListeners);
    }
    return retryTemplate.execute(callback, recoveryCallback);
}
Also used : RetryTemplate(org.springframework.retry.support.RetryTemplate) BackOffPolicy(org.springframework.retry.backoff.BackOffPolicy) NoBackOffPolicy(org.springframework.retry.backoff.NoBackOffPolicy) NoBackOffPolicy(org.springframework.retry.backoff.NoBackOffPolicy) NeverRetryPolicy(org.springframework.retry.policy.NeverRetryPolicy) InterceptorRetryPolicy(org.springframework.cloud.client.loadbalancer.InterceptorRetryPolicy) LoadBalancedRetryPolicy(org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy) NeverRetryPolicy(org.springframework.retry.policy.NeverRetryPolicy) RetryListener(org.springframework.retry.RetryListener)

Example 2 with NeverRetryPolicy

use of org.springframework.retry.policy.NeverRetryPolicy in project spring-cloud-netflix by spring-cloud.

the class RetryableOkHttpLoadBalancingClient method executeWithRetry.

private OkHttpRibbonResponse executeWithRetry(OkHttpRibbonRequest request, LoadBalancedRetryPolicy retryPolicy, RetryCallback<OkHttpRibbonResponse, Exception> callback, RecoveryCallback<OkHttpRibbonResponse> recoveryCallback) throws Exception {
    RetryTemplate retryTemplate = new RetryTemplate();
    BackOffPolicy backOffPolicy = loadBalancedRetryFactory.createBackOffPolicy(this.getClientName());
    retryTemplate.setBackOffPolicy(backOffPolicy == null ? new NoBackOffPolicy() : backOffPolicy);
    RetryListener[] retryListeners = this.loadBalancedRetryFactory.createRetryListeners(this.getClientName());
    if (retryListeners != null && retryListeners.length != 0) {
        retryTemplate.setListeners(retryListeners);
    }
    boolean retryable = isRequestRetryable(request);
    retryTemplate.setRetryPolicy(retryPolicy == null || !retryable ? new NeverRetryPolicy() : new RetryPolicy(request, retryPolicy, this, this.getClientName()));
    return retryTemplate.execute(callback, recoveryCallback);
}
Also used : RetryTemplate(org.springframework.retry.support.RetryTemplate) BackOffPolicy(org.springframework.retry.backoff.BackOffPolicy) NoBackOffPolicy(org.springframework.retry.backoff.NoBackOffPolicy) NoBackOffPolicy(org.springframework.retry.backoff.NoBackOffPolicy) NeverRetryPolicy(org.springframework.retry.policy.NeverRetryPolicy) InterceptorRetryPolicy(org.springframework.cloud.client.loadbalancer.InterceptorRetryPolicy) LoadBalancedRetryPolicy(org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy) NeverRetryPolicy(org.springframework.retry.policy.NeverRetryPolicy) RetryListener(org.springframework.retry.RetryListener)

Aggregations

InterceptorRetryPolicy (org.springframework.cloud.client.loadbalancer.InterceptorRetryPolicy)2 LoadBalancedRetryPolicy (org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy)2 RetryListener (org.springframework.retry.RetryListener)2 BackOffPolicy (org.springframework.retry.backoff.BackOffPolicy)2 NoBackOffPolicy (org.springframework.retry.backoff.NoBackOffPolicy)2 NeverRetryPolicy (org.springframework.retry.policy.NeverRetryPolicy)2 RetryTemplate (org.springframework.retry.support.RetryTemplate)2