Circuit Breaker: Author: Altaf Adil Mulesoft Solutions Architect

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10
At a glance
Powered by AI
The key takeaways are about circuit breaker design pattern, implementing circuit breakers using AMQ and custom policies.

Transient faults are temporary issues like slow networks or timeouts that typically resolve on their own, while outages involve partial or complete loss of connectivity and services and take longer to fix.

A circuit breaker pattern prevents applications from performing operations that are likely to fail by switching to an open state where requests immediately fail until the circuit breaker switches to a half-open state allowing a few requests to test if the operation works again.

Circuit Breaker

2020-06-04
Author: Altaf Adil
MuleSoft Solutions Architect
Agenda

 Problem and Context

 Circuit Breaker Design Pattern

 Circuit Breaker Using AMQ

 Circuit Breaker using Custom Policy


Problem and Context

In a distributed environment, calls to remote resources and services can fail due
to:

1. Transient Faults - Slow network connections


Timeouts
Resources being overcommitted
Temporarily unavailable

These faults typically correct themselves after a short period of time and can be
handled using retry pattern.

2. Outages - Partial loss of connectivity


Complete failure of a service

These faults might take much longer to fix and might be pointless for an
application to continually retry an operation

All contents © MuleSoft Inc. 3


Solution

Circuit Breaker Design Pattern

A circuit breaker is an automatic switch that stops the flow of electricity in the event of a
failure. This sort of behavior is also useful when integrating with remote systems.

The Retry pattern enables an application to retry an operation in the expectation that it'll
succeed. The Circuit Breaker pattern prevents an application from performing an operation
that is likely to fail.

An application can combine both retry and circuit breaker patterns.

All contents © MuleSoft Inc. 4


Circuit Breaker Pattern

Closed: The request from the application is routed to


the operation.

Open: The request from the application fails


immediately and an exception is returned to the
application.

Half-Open: A limited number of requests from the


application are allowed to pass through and invoke
the operation.

All contents © MuleSoft Inc. 5


Circuit Breaker Using AMQ

All contents © MuleSoft Inc. 6


Circuit Breaker Using AMQ

Configure the Subscribe processor:


     Subscriber Type – Prefetch
     Acknowledgment Mode – Set to MANUAL

As the Acknowledgement Mode is set to MANUAL, we


need to Ack the message post successful completion of
the flow. So that the message doesn’t get retried

In case of Error Scenarios:

Technical Errors - Catch the error and subsequent to Error


Handling, Nack the message so that the message stays on
the queue and will be subsequently redelivered.

Functional Errors – Catch the error and subsequent to


Error Handling, Ack the message so that the message is
removed from the queue.

All contents © MuleSoft Inc. 7


Why create Custom Policy

Disadvantages of Circuit Breaker using AMQ


1. Using AMQ requires modification to existing API
2. AMQ is NOT included in base subscription
3. In manual ACK mode, a message may timeout before processing is completed,
resulting in possible duplicate processing
4. Error handling needs to be changed in existing code

Advantages of Custom Policy


5. Can be applied to existing APIs without modification
6. Reusable across an organization
7. Can be reprocessed instantly if Circuit Breaker is open by deleting OS entry
All contents © MuleSoft Inc. 8
Circuit Breaker Custom Policy Flow

All contents © MuleSoft Inc. 9


Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy