问题
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 ?
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
EDIT : Problem was found with Spring Cloud Camden / Spring Boot 1.4.
回答1:
VM options and environment variables can be referenced from application configuration, which is often a more convenient way to set properties with longer names.
For example, one can define the following reference in application.yml
:
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: ${service.timeout}
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):
export service.timeout=10000
export service_timeout=10000
export SERVICE.TIMEOUT=10000
export SERVICE_TIMEOUT=10000
The common approach is to use lowercase.dot.separated
for VM arguments and ALL_CAPS_WITH_UNDERSCORES
for environment variables.
回答2:
Found more of a workaround than a solution, using SPRING_APPLICATION_JSON environment variable :
SPRING_APPLICATION_JSON='{ "hystrix" : { "command" : { "default" : { "execution" : { "isolation" : { "thread" : { "timeoutInMilliseconds" : 3000 } } } } } } }'
回答3:
You can use Spring config yaml file , Please read further on following link
https://github.com/spring-cloud/spring-cloud-netflix/issues/321
回答4:
You could try expression with a default value:
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: ${SERVICE_TIMEOUT:2000}
In case you have SERVICE_TIMEOUT
system variable - it will be used by an application, otherwise, a default value will be picked up.
回答5:
VM option -Dhystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=2000
works for me. However it has a side effect, then you can not change the config value in java code since system properties are prioritized.
ConfigurationManager.getConfigInstance().setProperty(
"hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds", 3000);// it doesn't work
来源:https://stackoverflow.com/questions/42072591/setting-hystrix-timeout-with-environment-variable