当前位置:   article > 正文

Hystrix-超时设置_hystrix isolation thread

hystrix isolation thread

使用@HystrixCommand注解

如果我们使用的是@HystrixCommand注解,那么可以在注解中直接指定超时时间,如下:

@HystrixCommand(fallbackMethod="fallback",
	commandProperties = {
	     @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1000" )
	}
)
  • 1
  • 2
  • 3
  • 4
  • 5

Hystrix配置整体的超时时间

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=1000
  • 1

配置单个超时时间

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>    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

在fegin中配置超时时间

在fegin中无法使用@HystrixCommand来单独进行配置

hystrix.command.MyService#getLastTimeData(Map).execution.isolation.thread.timeoutInMilliseconds
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/843133
推荐阅读
相关标签
  

闽ICP备14008679号