Failover and Circuit Breaker with Resilience4j

Rob Golder
Lydtech Consulting
Published in
10 min readDec 10, 2021

--

Failover and Circuit Breaker with Resilience4j

As with the adoption of any new tool or library it is usual to spike its usage to gain a good understanding of it, prove whether it is fit for purpose, and whether it meets the requirements of the project. To that end I looked at using resilience4j for two aspects of fault tolerance, namely failover and the circuit breaker, within a Spring Boot application.

Demo Application

For this demo a Spring Boot application has been developed which illustrates these patterns. A REST API provides an endpoint which when called attempts performs a lookup against a banking system to retrieve the bank account details for the provided request parameters, iban, country and currency. The application can be viewed in full in Github, and is referenced throughout this blog.

The application is a Spring Boot application. Spring Boot has first class support for Resilience4j, with provision of a resilience4j-spring-boot2 library.

Included in the project are integration tests that are used to demonstrate the functionality. Wiremock is used to mock the third party provided (3PP) services allowing simulation of the required behaviour that results in failover and the circuit breaker state changes being triggered.

--

--