You can add a Retryer in the FeignClientConfig

@Configuration
public class FeignClientConfig {

    @Bean
    public Retryer retryer() {
        return new Custom();
    }

}

class Custom implements Retryer {

    private final int maxAttempts;
    private final long backoff;
    int attempt;

    public Custom() {
        this(2000, 3);
    }

    public Custom(long backoff, int maxAttempts) {
        this.backoff = backoff;
        this.maxAttempts = maxAttempts;
        this.attempt = 1;
    }

    public void continueOrPropagate(RetryableException e) {
        if (attempt++ >= maxAttempts) {
            throw e;
        }

        try {
            Thread.sleep(backoff);
        } catch (InterruptedException ignored) {
            Thread.currentThread().interrupt();
        }
    }

    @Override
    public Retryer clone() {
        return new Custom(backoff, maxAttempts);
    }
}

Updated with sample Retryer example config based on the Retryer.Default.

Answer from Jeff on Stack Overflow
🌐
Spring
docs.spring.io › spring-cloud-openfeign › docs › current › reference › html
Spring Cloud OpenFeign
Notice this retrying behavior is different from the Feign default one, where it will automatically retry IOExceptions, treating them as transient network related exceptions, and any RetryableException thrown from an ErrorDecoder.
🌐
Medium
mohewedy.medium.com › how-to-enable-retry-for-some-methods-in-openfeign-4e02d05a81fd
How to enable retry for selected methods in OpenFeign | by Mohammed Hewedy | Medium
June 10, 2023 - As the Javadoc on top of the annotation works, it works by first creating a Retryer bean of type `AnnotationRetryer` that accepts a delegate Retryer (could be new `Retryer.Default()`) and then just placing the annotation `@FeignRetryable` on top of the method you need to retry it on failures.
🌐
Medium
engineering.getmidas.com › using-spring-retryable-with-feign-client-methods-9f77e509ad55
Using Spring @Retryable with Feign Client Methods | by Güven Seçkin | Midas Engineering
November 9, 2021 - To solve this problem, we used Aspect-Oriented Programming and wrote our own custom annotation: @FeignRetry. This annotation works like a wrapper for @Retryable and shares the same specs with it to avoid confusion.
🌐
GitHub
gist.github.com › mhewedy › 5a1b68f0a19edf6b4060e74cce3d0015
Annotation for feign retry · GitHub
I'm using Feign Client with Java Annotations, like: @FeignClient(value="myClient", url="URL", configuration="MyConfig.class"). I've added the @Bean Retryer to MyConfig class and annotated the called method with @FeignRetryer interface.
🌐
Baeldung
baeldung.com › home › rest › retrying feign calls
Retrying Feign Calls | Baeldung
February 3, 2022 - Alternatively, if we use Spring, we could let it auto-wire Feign client with available beans. Fortunately, retrying abilities are baked in Feign, and they just need to be configured.
🌐
Medium
waqarmansoor.medium.com › how-to-configure-feign-client-retry-mechanism-4b9740144bb4
How to configure Feign client retry mechanism ? | by Waqar Mansoor | Medium
March 15, 2020 - In the above code we are trying to configure “No Retry” for only order service which we are taking it from application properties and application context at the time of bean creation helps to distinguish the specific bean by using the getDisplayName() method. Always remember it is the property of spring cloud to create an ensemble of components aka application context on demand for each and every named feign client component, the name of the component is taken from @FeignClient annotation.
🌐
GitHub
github.com › OpenFeign › feign-annotation-error-decoder › issues › 25
[Question] - Annotation based Retry After Exception · Issue #25 · OpenFeign/feign-annotation-error-decoder
July 18, 2019 - I'm trying to implement a RetryAfterException that gets automatically retried, but without duplicating Feign's RetryAfterDecoder (or putting my exception class in the feign.codec package).
Author: OpenFeign
🌐
Tech Me More
diehardtechy.com › 2020 › 05 › openfeign-retry-request-based-on-custom.html
OpenFeign : retry request based on custom HTTP response status - Tech Me More
The above decoder will return the Retryable exception if the response code is 404. We can customize it for our own purpose or logic. Please remember to pass response.request() and not null in the last parameter. We can also customize how many times we want to retry and the interval before retrying. Feign comes with feign.
Find elsewhere
🌐
Wordpress
buddhimawijeweera.wordpress.com › 2020 › 01 › 29 › error-decoding-and-retrying-with-feign-clients
Error Decoding and Retrying with Feign Clients – BUDDHIMA'S COMPUTER LAB
February 1, 2020 - To enable feign clients, you need to use @EnableFeignClients annotation in the main class definition. Then you can simply create an interface to the external web-services.
🌐
GitHub
github.com › resilience4j › resilience4j › issues › 1234
Retry support for Feign clients · Issue #1234 · resilience4j/resilience4j
October 30, 2020 - Feign client is a very popular alternative to RestTemplate or newer REST-based clients. As far as I see in the current guide website Feign Guide for v1.6.1, Resilience4j provides no support of the Retry module for Feign clients: Current ...
Author: resilience4j
🌐
Learnspringbootonline
learnspringbootonline.com › blog › feign-retry-mechanism-spring-boot
Feign Retry Mechanism Spring Boot | Retry Failed API Call
March 18, 2024 - import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @FeignClient(name = "learn-spring-boot-online-service", url = "https://learnspringbootonline.com") public interface LearnSpringBootOnlineFeignClient { @GetMapping("/endpoint") String fetchData(); } Configure the retry mechanism for Feign.
🌐
Medium
medium.com › swlh › how-to-customize-feigns-retry-mechanism-b472202be331
How to Customize Feign’s Retry Mechanism | by Ruhshan Ahmed Abir | The Startup | Medium
July 15, 2024 - In a perfect world, everything works perfectly and we don’t have to retry any http requests. Thus retry is not enabled in feign out of the box. Unfortunately this never happens, for a tcp packet there are a millions ways to die in the web.
🌐
Learnspringbootonline
learnspringbootonline.com › blog › spring-boot-feign-retry
Feign Retry Logic Implementation In Spring Boot
September 8, 2024 - Spring Boot’s Feign client doesn’t natively support retries out of the box, but you can implement retries by integrating Spring Retry or configuring Resilience4j for Feign.
🌐
Medium
medium.com › @ashishbakwad2010 › spring-boot-resilience4j-retry-with-feign-client-41633cb213ce
Spring Boot Resilience4j Retry With Feign Client | by Ashish Bakwad | Medium
July 19, 2022 - You can find more retry properties details at documentation if needed. ... Join Medium for free to get updates from this writer. ... @FeignClient(name = "ProductService", url = "${testapi.url}") @Retry(name = "ProductServiceRetry") public interface ProductService { @RequestMapping(method = RequestMethod.GET, value = "/products/{id}") ProductModel getProductById(@PathVariable Integer id); }
🌐
DEV Community
dev.to › sabyasachi › spring-feign-client-3853
Spring Feign Client - DEV Community
August 28, 2022 - Feign has baked in support for retry mechanism. However by default it uses Retry.NEVER_RETRY . For example we can create a custom retryer which will retry any status code > 400.
🌐
DZone
dzone.com › software design and architecture › microservices › configurable feign client retry with reusable library and dry
Configurable Feign Client Retry With Reusable Library, DRY
December 4, 2024 - This article demonstrates how to implement retry logic with conditional configuration to Feign client and package it in a common library using Maven. The idea is to use it to expose Feign retry and features similar to those of the consumer of this library. It also helps in the Separation of Concerns.
🌐
GitHub
github.com › OpenFeign › feign › blob › master › core › src › main › java › feign › Retryer.java
feign/core/src/main/java/feign/Retryer.java at master · OpenFeign/feign
* Cloned for each invocation to {@link Client#execute(Request, feign.Request.Options)}. * Implementations may keep state to determine if retry operations should continue or not. */ public interface Retryer extends Cloneable { · /** * if retry is permitted, return (possibly after sleeping).
Author: OpenFeign
🌐
Stack Overflow
stackoverflow.com › questions › 62814465 › how-to-properly-configure-fallback-and-retryer-for-feignclient
spring boot - How to properly configure fallback and retryer for @FeignClient? - Stack Overflow
@FeignClient(name = "some-client", url = "${some-client.url}") public interface SomeClient { @GetMapping(value = "/api/some-endpoint", produces = MediaType.APPLICATION_JSON_VALUE) List<SomeDto> searchForAllDtos(@RequestParam("param") String param); } ... @Configuration public class ClientConfiguration { @Bean public Retryer retryer(@Value("${http.retry.period}") long period, @Value("${http.retry.maxPeriod}") long maxPeriod, @Value("${http.retry.maxAttempts}") int maxAttempts) { return new CustomRetryer(period, maxPeriod, maxAttempts); } @Bean public ErrorDecoder decoder() { return new CustomDe