Circuit Breaker Module

I guess that we more often think about our services in a “happy path” term, but we underestimate not so happy paths. What if my API is trying to reach another API/system and it is failing constantly? Can I reach it less often in case of a timeout? I thought about that in case of a Mule 4 application and I came up with Circuit Breaker pattern. In this article, I will briefly introduce the pattern and show you how you use it in your Mule application.

Circuit Breaker Pattern

Circuit Breaker monitors API calls. When everything is working as expected, it is in the state closed. When the number of fails, like timeout, reaches a specified threshold, Circuit Breaker will stop processing further requests. We call it the open state. As a result, API clients will receive instant information that something went wrong without waiting for the timeout to come.