【发布时间】:2023-04-10 13:13:01
【问题描述】:
我让 Hystrix 在我的 Spring Boot 应用程序中使用 Feign。
我已将 Hystrix 的默认超时设置为 10000 毫秒:
feign:
hystrix:
enabled: true
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 10000
问题是我有这个客户,我们称它为HeavyClient,这是一个繁重的调用,有时需要更多时间并导致电路中断。
我想只为这个人增加 Hystrix 中的超时上限。有可能吗?
我尝试过使用 Feign 属性,例如:
feign:
client:
config:
HeavyClient:
connectTimeout: 30000
readTimeout: 30000
但这不起作用。我猜 Hystrix 不会检查 Feign 属性。
我正在使用:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
感谢任何帮助,谢谢!
【问题讨论】:
-
如果您在依赖(重客户端)级别设置 hystrix 超时,您可以这样做。您可以通过 hystrix 命令键识别重客户端。
-
Hystrix.command.heavyclient.execution.isolation.thread.timeoutInMilliseconds = 40000 。这里的heavyclient是你的命令键。
-
嗨@IndraneelBende,我试过了,使用我给
@FeignClient的相同ID,但它不起作用。它仍然使用default超时
标签: java spring-boot hystrix spring-cloud-feign feign