I'm implementing a circuit breaker pattern with Hystrix. It seems to be working, but now I want to fetch certain Hystrix properties from my application properties with prefixes.--
It looks like I should be using Archaius ConfigurationManager but the wiki is all words and little code. This Q&A comes close but I don't understand their implementation (http://stackoverflow.com/questions/35085617/how-to-configure-hystrix-annotations-from-property-file).
My current circuit breaker looks like so:
@HystrixCommand(fallbackMethod = "enroll", commandProperties ={
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "650")
}
public ResponseEntity<byte[]> EnrollReq (params....){
//code
}
public ResponseEntity<byte[]> enroll(params...){
//return error status
}
I want to fetch the timeoutInMilliseconds from my application.properties which has this in it:Hystrix.Enroll.TimeoutInMilliseconds=650
I've created a specific class for HystrixCommandProperties:@ConfigurationProperties(prefix = "Hystrix.Enroll")
@Data
public class HystrixCommandProperties {
private int TimeoutInMilliseconds
}
I'm definitely missing some sort of connection between the stored spring configuration and the Hystrix syntax. I want the value = "650" in my circuit breaker to use the Hystrix.Enroll.TimeoutInMilliseconds instead.
You received this message because you are subscribed to the Google Groups "HystrixOSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hystrixoss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to hystrixoss+...@googlegroups.com.
@ControllerRuntimeProfiling(prefix = "enroll", logger = RequestLogger.class)
@HystrixCommand(fallbackMethod = "enroll")
public ResponseEntity<byte[]> EnrollReq (params....){
//code
}
public ResponseEntity<byte[]> enroll(params...){
//return error status and logs
}
Hystrix Command Properties:
@Data
public class HystrixcommandProperties {
private int timeoutInMilli = 5000;
private int maxConReq = 200;
//logger if wanted
public HystrixCommandProperties init(String name){
ConfigurationManager.getConfigInstance().setProperty(String.format("hystrix.command.$s.excution.isolation.thread.timeout", name), timeoutInMilli);
//same for conreq
//logger if you want
return this;
}
}
HystrixConfig (Bean creation):
@Configuration
public class HystrixConfig {
@Bean
@ConfigurationProperties(prefix = "Hystrix.Enroll")
public HystrixCommandProperties enrollHystrixProperties(){
return new HystrixCommandProperties().init("processEnrollmentRequest");
}
//more beans here if needed
}
And then you also add the properties as required. Make sure to add them to staging and dev as well. The code was re-typed so I apologize for any typing mistakes.