Questions Management – Enable Circuit Breaker for API and Composite services using Hystrix from Spring Cloud Netflix

Check out the full series of Questions Management tutorial here.

Applying Circuit Breaker for services in Questions Management application is very important to ensure that problems occur that need solutions to solve quickly and promptly. I will use Hystrix to do this.

You can learn more about Hystrix and Hystrix for Reactive application if you want.

In the Questions Management application, API and Composite services are services that will call other services to retrieve data. Therefore, I will declare using Hystrix dependency in these services as follows:

Next, I will go to each service to enable Circuit Breaker and correct the call to other services that support Hystrix as follows:



API Category Service

ApiCategoryServiceApplication:

CoreCategoryServiceImpl:




API Option Service

ApiOptionServiceApplication:

CompositeOptionServiceImpl:

CoreOptionServiceImpl:




API Question Service

ApiQuestionServiceApplication:

CompositeQuestionServiceImpl:




Composite Question Service

CompositeQuestionServiceApplication:

CoreCategoryServiceImpl:

CoreOptionServiceImpl:

CoreQuestionServiceImpl:




Composite Option Service

CompositeOptionServiceApplication:

CoreOptionServiceImpl:

CoreQuestionServiceImpl:

That’s it! You can test this Circuit Breaker as follows:

– Start all applications up:

Questions Management - Enable Circuit Breaker for API và Composite services using Hystrix from Spring Cloud Netflix

– Request to get information of a question:

Questions Management - Enable Circuit Breaker for API và Composite services using Hystrix from Spring Cloud Netflix

– Turn off Core Option Service:

Questions Management - Enable Circuit Breaker for API và Composite services using Hystrix from Spring Cloud Netflix

– Request to question above again, you will see that the result still returns as usual without the option information as follows:

Questions Management - Enable Circuit Breaker for API và Composite services using Hystrix from Spring Cloud Netflix

Add Comment