赞
踩
如果我们使用的是@HystrixCommand注解,那么可以在注解中直接指定超时时间,如下:
@HystrixCommand(fallbackMethod="fallback",
commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1000" )
}
)
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=1000
hystrix.command.HystrixCommandKey.execution.isolation.thread.timeoutInMilliseconds=1000
其中HystrixCommandKey为@HystrixCommand 进行配置
example
@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission")
public String storeSubmission(ReturnType returnType, InputStream is, String id) {
}
@HystrixCommand需要引入依赖
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
<version>${hystrix-version}</version>
</dependency>
在fegin中无法使用@HystrixCommand来单独进行配置
hystrix.command.MyService#getLastTimeData(Map).execution.isolation.thread.timeoutInMilliseconds
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。