Spring Cloud Netflix - Hystrix and properties

My Spring certification preparation are on hold because some trainings are ahead I have to prepare for. One will be Spring Boot withSpring Cloud. I have been working with Spring Boot for 4 years now and am a huge fanboy. Spring Cloud is something I looked into and we use Hystrix in a project but I have been scratching the surface mostly.
One thing I learned in my preparation I want to share with you because it took me some hours since I finally found my mistake.
On the mentioned project we use Hystrix like it's shown on the Javanica page:



    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "500")
        })
    public User getUserById(String id) {
        return userResource.getUserById(id);
    }

Now I wanted to configure some default properties in my application.yaml. I took the values like the above "execution.isolation.thread.timeoutInMilliseconds" and put it into my file: Nothing happended. I went to the Spring docs looking for a list of properties like in the Spring Boot appendix, but found only the Appendix: Compendium of Configuration Properties. There they only put spring specific properties. In the hystrix section they mention "circuitBreaker.requestVolumeThreshold" and such which all do not work. One source sent me to the Netflix Config page where I find the already mentioned properties. Finally I looked deeper into some explanations and there I found that the mentioned properties are something like captions and the correct properties can be found as Default Property or Instance Property like "hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds". So I put "hystrix.command.default" before every property and now it's working...
And before I forget it: If you want to get Hystrix working with feign, you not only have to have it on the classpath and annotate your main class with @EnableHystrix and @EnableFeignClients but you also have to add the property "feign.hystrix.enabled=true"!

Kommentare

Beliebte Posts aus diesem Blog

Another Spring Mock Exam Simulator