使用环境变量设置 Hystrix 超时 [英] Setting Hystrix timeout with environment variable

查看:40
本文介绍了使用环境变量设置 Hystrix 超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了改变 Hystrix 的默认请求超时(1000ms),必须设置以下属性:hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=2000

In order to change Hystrix's default request timeout (1000ms), one must set the following property : hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=2000

对应的环境变量是什么?

What is the corresponding environment variable ?

我想在不接触源代码的情况下在我最喜欢的云平台上调整"超时.我很确定这个不起作用:HYSTRIX_COMMAND_DEFAULT_EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS=2000

I would like to "tune" the timeout on my favorite cloud platform without touching the source code first. I'm pretty sure this one doesn't work : HYSTRIX_COMMAND_DEFAULT_EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS=2000

在 Spring Cloud Camden/Spring Boot 1.4 中发现问题.

EDIT : Problem was found with Spring Cloud Camden / Spring Boot 1.4.

推荐答案

可以从应用程序配置中引用 VM 选项和环境变量,这通常是设置具有较长名称的属性的更方便的方法.

VM options and environment variables can be referenced from application configuration, which is often a more convenient way to set properties with longer names.

例如,可以在application.yml中定义如下引用:

For example, one can define the following reference in application.yml:

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: ${service.timeout}

这将通过 VM 选项 -Dservice.timeout=10000 解决,将默认的 Hystrix 命令超时设置为 10 秒.使用环境变量甚至更简单 - 感谢 relaxed binding,其中任何一个都可以工作(export 示例适用于 Linux):

which will be resolved from the VM option -Dservice.timeout=10000, setting the default Hystrix command timeout to 10 seconds. It is even simpler with environment variables - thanks to relaxed binding, any of these will work (export examples are for Linux):

  • 导出 service.timeout=10000
  • 导出 service_timeout=10000
  • 导出SERVICE.TIMEOUT=10000
  • 导出SERVICE_TIMEOUT=10000

常见的方法是使用 lowercase.dot.separated 作为 VM 参数,使用 ALL_CAPS_WITH_UNDERSCORES 作为环境变量.

The common approach is to use lowercase.dot.separated for VM arguments and ALL_CAPS_WITH_UNDERSCORES for environment variables.

这篇关于使用环境变量设置 Hystrix 超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆