1

I want to manage retries. I have openfeign client, two micro-services. How to do it? When i set in my yaml configuration:

foo:
    ribbon:
        MaxAutoRetries:5

It doesn't work. In my pom.xml is Spring Cloud Greenwich RELEASE, spring-retry and open-feign dependencies. I don't use any service discovery.

I added to my feign method annotations: @FeignClient(name="foo", url="...") and @RibbonClient(name="foo").

I don't see any ribbon logs after start application and when i do http feign request. Should ribbon be configured on both microservices?

vertenon
  • 23
  • 5

1 Answers1

0

You can create a Configuration for Retryer's feign and set the values you want:

import feign.Retryer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignClientConfig {

    @Bean
    public Retryer retryer() {
         //  Default(long period, long maxPeriod, int maxAttempts)                       
        return new Retryer.Default(1, 100, 3);
    }
}
Jonathan JOhx
  • 5,784
  • 2
  • 17
  • 33
  • Is it possible to retry when second microservice return 500? Now it's work when second microservice is down. – vertenon Oct 15 '19 at 05:58
  • I found solution to retry on 500 and with Your solution this is what I need. Thanks. Retry on status codes: https://stackoverflow.com/questions/37614202/feign-retry-depending-on-response-status – vertenon Oct 15 '19 at 08:24