Considerations for Configuring a Circuit Breaker for a Service
The purpose of a using a circuit breaker with a service is to protect your application from failures of that service by monitoring the service for consistent failures and then preventing execution of the service until success is likely. Circuit breakers can be useful for services that communicate with distributed applications such as a service that connects to an application in the cloud or a database. By configuring a circuit breaker for the service, the continued inability to connect to the cloud or a database results in failure events which eventually result in the opening of the circuit.
When you configure a circuit breaker for a service, you must make the following key decisions.
What constitutes a failure event? An exception, a timeout, or both?
How many failure events must occur within a set time period before the circuit opens?
What action does the circuit breaker take upon receiving a request for the service with the open circuit?
How long does the circuit breaker wait before attempting to execute the service? That is, what is the circuit reset period after which the circuit state changes from open to half-open?
For more information about circuit breaker behavior and concepts, see Developing Microservices with webMethods Microservices Runtime
Keep the following information in mind when configuring a circuit breaker for a service.
You can configure a circuit breaker for a user-defined service only. That is, you cannot configure a circuit breaker for services in packages provided by
Software AG such WmPublic or WmRoot.
Using a circuit breaker with a service may impact service performance. However, the benefits of using a circuit breaker may outweigh the performance impact.
If the circuit breaker for a service considers a timeout to be a failure event and you want circuit breaker to attempt to cancel the thread executing the service, you must configure the thread kill functionality on the
Integration Server that hosts the service. Specifically, you must set the watt.server.threadKill.enabled and the watt.server.threadKill.interruptThread.enabled server configuration parameters to true. For more information about the thread kill functionality, including configuration information and limitations, see
webMethods Integration Server Administrator’s Guide.
When configuring a service to use circuit breaker and transient error handling, also known as service retry, keep in mind that circuit breaker could open the circuit before completing all of the retry attempts. The circuit breaker handles any subsequent retry attempts as it would any request for the service. For more information about how a circuit breaker works, see
Developing Microservices with webMethods Microservices Runtime.
When specifying an alternate service to invoke when a service has an open circuit, do not create a circular reference in which the service with the configured circuit breaker calls itself. If you do,
Integration Server throws the exception that caused the service to open instead of invoking the alternate service.