Step | Description |
1 | The server receives a request to invoke a service. Upon receiving a request to invoke a service, the server first determines whether or not a circuit breaker is configured for the service. ![]() ![]() |
2 | The circuit breaker examines the state of the circuit for the service. ![]() ![]() ![]() When executing a service in a half-open state, any other requests for the service wait until the circuit exits the half-open state. For more information, see step 8, below. |
3 | When the circuit state is closed, upon execution of the service by the circuit breaker, one of the following occurs: ![]() Note: If the Failure event property is set to Timeout only or Exception or timeout, a successful execution indicates that the service executed successfully within the specified timeout period. ![]() If the Failure event property is set to Exception only or Exception or Timeout, the circuit breaker considers the exception to be a failure event. The circuit breaker increments the failure count for the service by 1. ![]() If the Cancel thread on timeout property is set to true, the circuit breaker attempts to cancel the thread executing the service. If the service ends with a failure event and it is the first failure event, the circuit breaker starts the failure timeout period. If the number of failure events specified in Failure threshold property occurs before the failure timeout period ends, the circuit opens. Circuit breaker determines the time that the failure period ends by adding the number of seconds specified in the Failure period property to the time the first failure event occurred. If the service executes successfully and completes after the failure timeout period ends, circuit breaker resets the failure count for the service to 0. |
4 | Subsequent invocations of the service result in the circuit breaker opening or “tripping” the circuit for the service if: ![]() ![]() The circuit breaker starts the reset period which determines the length of time to keep the circuit in an open state. The Circuit reset period property determines the length of the reset period. For example, suppose that circuit breaker treats exceptions as a failure event, the Failure threshold property is set to 5, and the Failure period is set to 60 seconds. Further suppose that the first failure event occurs at 10:07:10. Circuit breaker starts the failure timeout period. The failure timeout period ends at 10:08:10 which circuit breaker determines by adding the Failure period value to the time of the first failure event. If 5 invocations of the service end with an exception in less than 60 seconds, that is, before 10:08:10, the circuit breaker opens the circuit for the service. |
5 | When the circuit breaker receives a request to execute the service, the circuit breaker does one of the following: ![]() ![]() Note: When the circuit is open, circuit breaker does not use the circuit breaker thread pool to throw the exception or execute the alternate, open circuit service. Instead, circuit breaker uses the same thread that executes the calling service to return the exception or execute the alternate, open circuit service. |
6 | The circuit breaker repeats the previous step in response to a request for the service until the time specified in the Circuit reset period property elapses. |
7 | When the circuit reset period elapses, the circuit breaker sets the circuit to a half-open state. |
8 | The circuit breaker receives a request for the service. ![]() ![]() ![]() ![]() |