简体   繁体   English

Spring Cloud:如何在@FeignClient中配置Hystrix

[英]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? 如何更改默认超时和线程池大小?

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. 如果要管理Feign的配置,则需要查看@FeignClient批注的“ configuration”属性来查看Feign文档。

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);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM