主要问题是,我使用groupKey值而不是commandKey值来定义属性。这些配置属性的Wiki页面-https:
//github.com/Netflix/Hystrix/wiki/Configuration#intro说-
hystrix.command.HystrixCommandKey.execution.isolation.thread.timeoutInMilliseconds
将属性的HystrixCommandKey部分替换为您为commandkey设置的值。
hystrix.threadpool.HystrixThreadPoolKey.coreSize
将属性的HystrixThreadPoolKey部分替换为您为threadPoolKey设置的值。
这是我在HystrixCommand包装的方法上同时定义commandKey和threadPoolKey的方法-
@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission")public String storeSubmission(ReturnType returnType, InputStream is, String id) {}您实际上可以在 @HystixCommand 批注中的方法上定义命令和 线程池 属性。
@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission", commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000"), @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "4"), @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "60000"), @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") }, threadPoolProperties = { @HystrixProperty(name = "coreSize", value = "30"), @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") })public String storeSubmission(ReturnType returnType, InputStream is, String id) {}我想定义这些属性的最佳方法是在externalized application.yaml中,这样您可以更好地控制它并针对不同的环境进行更改。



