I want to predefine global configuration for all the hystrix commands in my project. I.e. I want to mark methods only with something like this:
@HystrixCommand(commandKey = "MFO_SERVICE", fallbackMethod = "fallback")
not like this
@HystrixCommand(
commandKey = "MFO_SERVICE",
commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1000"),
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "60000"),
@HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "10"),
@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "50"),
@HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "60000")},
fallbackMethod = "fallback")
And all the params should be stored at property file and should be able to change without re-compiling. So I'm trying to use a spring component that takes a param from enironment and injects it into the Hystrix (Archaius) ConfigurationManager.
@Component
public class HystrixConfig {
@Value("${execution.isolation.thread.timeoutInMilliseconds}")
private String timeoutInMilliseconds;
@PostConstruct
private void init() {
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.MFO_SERVICE.execution.isolation.thread.timeoutInMilliseconds", timeoutInMilliseconds);
}
}
But it takes no effect. It seems to be no hystrix command exists at Spring @PostConstruct moment. And finally I got a HystrixCommand with default config.
Is there any way to resolve it?