It seems that I have not written relevant articles, just recently some friends asked me about some problems encountered in the new version.

2020.0.1 is the latest version and the one with the most changes. The biggest change is the removal of Netflix OSS components. Today’s question is also related to that, as you can see from the title.

Although the Netflix component has been removed, for beginners, most books or articles on the market are old versions, which are also used in The Netflix component. When learning, I choose the latest version naturally, but I do not carefully read the official documents, nor do I know that the latest version has been removed. When using these components, I still use them in the way of the old version, which naturally causes problems.

The problem background

The service invocation uses Feign, also adds The Hystrix configuration and dependencies, and also writes the fallback logic. Taking the service provider offline, calling the interface, but not backing back the logic, proves that Hystrix is not working.

The configurations to enable Feign support for Hystrix are as follows:

feign.hystrix.enabled=true
Copy the code

If it doesn’t work, the best way to find the problem is through source code, starting with Feign’s autoloader code, class FeignAutoConfiguration.

. Then you will find that already can’t find the feign hystrix, enabled, and corresponding new control assembly is feign circuitbreaker, enabled.

So the first reason it doesn’t work is because the configuration is wrong and needs to be changed to the following:

feign.circuitbreaker.enabled=true
Copy the code

After I changed it, it still didn’t work. I had no choice. I asked for a copy of the code and looked at the new version, which abstracted the CircuitBreaker interface in Commons. But there are no implementation classes, which means Hystrix has a problem, either relying on the wrong version or being too low to fit.

The current version in use is 2.1.6.release.

<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> < version > 2.1.6. RELEASE < / version > < / dependency >Copy the code

Then go to mvnRepository and use a new version 2.2.6 to find the CircuitBreaker implementation class.

After these two steps, the logic of the Hystrix rollback works.

This article is mainly to share the idea of solving the problem, I hope you have a harvest.

About the author: Yin Jihuan, a simple technology lover, the author of Spring Cloud Micro-service – Full stack Technology and Case Analysis, Spring Cloud Micro-service Introduction combat and Progress, the founder of the public account Monkey World.