Neo
Neo

Reputation: 2226

Spring Cloud: How to configure Hystrix in @FeignClient

I have following service:

@FeignClient(name = "person", fallback = FeignHystrixFallback.class)
public interface PersonService {

    @RequestMapping(value = "/find", method = RequestMethod.GET)
    Person findPerson(@RequestParam("name") String name);
}

How to change the default timeout and thread pool size?

Upvotes: 0

Views: 3391

Answers (2)

koa73
koa73

Reputation: 881

Set custom configuration for this interface

@FeignClient(name="person", configuration = FeignConfig.class)

and make configuration

public class FeignConfig {
    public static final int FIVE_SECONDS = 5000;

    @Bean
    public Request.Options options() {
        return new Request.Options(FIVE_SECONDS, FIVE_SECONDS);
    }
}

Upvotes: 0

Shawn Clark
Shawn Clark

Reputation: 3440

There are other people that have run into this issue and have posted questions and have answers. The most relevant is this post:

Feign builder timeouts not working

If you are wanting to manage the configuration of Feign you would want to check out the Feign documentation looking at the "configuration" attribute of the @FeignClient annotation.

Upvotes: 1

Related Questions