Before we add a circuit breaker and a retry mechanism to the source code, we will add code that makes it possible to force an error to occur—either a delay and/or a random fault. Next, we will add a circuit breaker to handle slow or not responding APIs, as well as a retry mechanism that can handle faults that happens randomly. Adding these features from Resilience4j follows the traditional Spring Boot way:
- Add a starter dependency for Resilience4j in the build file.
- Add annotations in the source code where the circuit breaker and retry mechanism shall be applied.
- Add configuration that controls the behavior of the circuit breaker and retry mechanism.
Once we have the circuit breaker and retry mechanism in place, we will extend our test script, test-em-all...