在我的Spring应用程序中,我有一个冒充的Hystrix工作。
我已经将Hystrix的默认超时设置为10000 to,如下所示:
feign:
hystrix:
enabled: true
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 10000问题是,我有一个客户,让我们称之为HeavyClient,这是一个沉重的调用,有时需要更多的时间,并导致电路中断。,我想增加超时值上限,只为这一个人。有可能吗?
我试过一些假冒伪劣的东西,比如:
feign:
client:
config:
HeavyClient:
connectTimeout: 30000
readTimeout: 30000但这不管用。我想Hystrix不会检查冒牌货。
我在用:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>任何帮助都是感激的,谢谢!
发布于 2021-03-04 17:22:43
在that上进行了更深入的搜索之后,我在这个GitHub问题上发现,默认的Hystrix命令命名类似于InterfaceName#methodNameSignature()。
因此,例如,给定以下@FeignClient
@FeignClient(name = "heavyClient", url = "${heavyclient.url}")
public interface HeavyClient {
@RequestMapping("/process/{operation}")
public ResponseEntity<Response> process(@PathVariable("operation") String operation);
}它将被配置为:
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 5000
HeavyClient#process(String):
execution:
isolation:
thread:
timeoutInMilliseconds: 30000不幸的是,这对我没有用.不知道为什么..。因此,为了解决这个问题,我注册了一个SetterFactory类型的bean,它将创建给定@FeignClient名称的命令键:
@Bean
public SetterFactory setterFactory() {
return (target, method) -> HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(target.name()))
.andCommandKey(HystrixCommandKey.Factory.asKey(target.name()));
}然后,我可以简单地使用以下配置:
hystrix:
command:
heavyClient:
execution:
isolation:
thread:
timeoutInMilliseconds: 30000发布于 2022-02-24 11:48:52
CircuitBreakerNameResolver将电路命名为HystrixCommandKey,有一个默认的实现DefaultCircuitBreakerNameResolver,它的输出键模式是HardCodedTarget#methodName(ParamClass),所以您可以定制CircuitBreakerNameResolver而不是DefaultCircuitBreakerNameResolver。
https://stackoverflow.com/questions/66355496
复制相似问题