栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Spring-Boot应用程序中使用application.yaml配置hystrix命令属性

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Spring-Boot应用程序中使用application.yaml配置hystrix命令属性

主要问题是,我使用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中,这样您可以更好地控制它并针对不同的环境进行更改。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/430511.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号