A circuit-breaker is best thought of as a state machine, with three main states.
Closed
The circuit initially starts closed. When the circuit is closed:
• | The circuit-breaker executes actions placed through it, measuring the faults and successes of those actions. these actions are commonly messages to send to a third party. |
• | If a fault (e.g. the provider does not respond) occurs more than a certain number of times (set in the Error Threshold), the circuit will break (open). |
oan error log will be created
oa message will be sent to our IT Support department
• | For the action causing the circuit to trip, the original reason of failure is re-sent to allow WebOffice to take proper actions to the calling service. |
Open
While the circuit is in an open state:
• | Any action placed for execution through the policy will not be executed. Instead, the call will fail immediately with a BrokenCircuitException. i.e. WebOffice will send a request failed back to the caller (read terminal). This BrokenCircuitException contains the last reason for failure as the reason why the circuit is open. |
oA warning message will be created
• | The circuit remains open for the time configured in "Seconds to wait on Failure". After that time span, but before the next action, the circuit will change to a half open state. |
Half-Open
When the circuit is half-open:
• | the next action will be treated as a trial, to determine the circuit's health. Should that action take longer than the time set in "Seconds to wait on Failure" to return, a next attempt will be done after the time set in "Seconds to wait on Failure". |
• | A call to the receiver of the message will be attempted with the action delegate. |
o | If this call fails, the circuit will change to open immediately, and remains open again for the configured time span. |
o | If the call succeeds, the circuit will change to closed. |
oAn information message will be created.