Lab#30 Circuit Breaker With Fallback
In the previous lab, we implemented the circuit breaker but it had no fallback mechanism, so a runtime exception was thrown. Throwing exceptions to the client is not a valid approach. We need a fallback mechanism to send a message to the client. Step#1 In the gateway application we need to create a controller class to handle the fallback.

Figure 1. Controller package and FallbackController class
| Gateway Server: FallbackController.java | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Step#2 Integrate the fallback into the circuitbreaker pattern by modifying the GatewayserverApplication class. Restart the gateway.
| Gateway Server: GatewayserverApplication.java | |
|---|---|
18 19 20 21 22 23 24 25 26 | |
Step#3 Call the contact-info endpoint.

Figure 2. Call Contact Info Endpoint

Figure 3. Actuator Circuitbreakers
Now add the breakpoint again in the AccountController class

Figure 4. Add Breakpoint
Call the end point again and you will see the fallback was called.

Figure 5. Fallback message