Wage Gap

If you were able to look at all different perspectives, maybe put your feet in someone else’s shoes for one-second would you? Women have been treated very differently for years when it comes to equal…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Fault Tolerance with Spring Boot and Hystrix

This will be a very short story covering only the demo for Circuit breaker in microservice applications. I’ll create another story for fundamentals of fault tolerance and detailed analysis of Netfilx Hystrix vs Apache resilience4j library covering what’s better in which scenario as Hystrix has now officially closed it’s development.

Goal: We’ll be having some fallback methods for API failures and when our microservice will get down then system should automatically detect and handle this without affecting any other service. I’m using my existing spring application as my API supplier. It has few endpoints exposed on 8080 and some business logic connected with mysql. I’ve started mysql on 3306 via docker.

Now, create a controller and a service with a endpoint consuming some exposed API from our existing application. Here, I have used default URL class to consume URL objects.

A sample Controller class.

A Sample Service class.

Also, change the application port to something else than 8080. In my case I’m using 8090.

API working

To test, shutdown the running server on 8080.

Fallback worked!

Add a comment

Related posts:

The Tulsa Massacre

As I am writing this, the blood of the free citizens of the US is boiling looking at the aftermath of the non-violent protests over the killing of George Floyd in Minnesota. The incident re-ignited…

Human Encounter

The noonday sun tried to break through the canopy of trees. She sat at one of her favorite benches on Central park not too distant from her office. She looked past him, past his gaze, she sensed he’d…

Why Business Leaders Should Become Analytics Evangelists

Learn how business leaders can leverage data science and analytic tools to extract valuable insights and bridge the gap between data and decision-making.