Anypoint MQ Error Handling using MuleSoft Circuit Breakers – Mule 4

able of Contents 


Circuit breakers handle error scenarios and message reprocessing strategy and monitor the API calls. Find the Circuit breakers State explanation below, 

  • Closed State – Everything is working as expected.  
  • Open State –   Number of failures Like timeouts, reaches a threshold, circuit breakers will stop the processing further API requests.  


MuleSoft has provided the Anypoint MQ component itself the circuit breaker capability. 

Add the dependency on the pom file as below: 







Below is the Circuit Breaker with Anypoint MQ Example: 

Circuit Breaker Configuration: 

On the global elements section, Create the Circuit breaker configuration as below: 

This configuration can be used across multiple Subscriber resources in the project. 

  • On Error Types – Type of Errors which want to trigger Open State 
  • Errors Threshold – Number of Failures in Succession  
  • Trip Timeout – Duration of Circuit Open When the Error Threshold is reached  

Subscription Configuration:  

In Anypoint MQ Subscriber Configuration, Refer to Advanced and configure the Circuit Breaker on reference. 

It will handle the error scenarios and message reprocessing strategy if there are any failures. 

AMQ Message Processing Listening Strategy: 

This explains, what we are going to follow to process messages from Anypoint MQ. This process helps in effectively handling reprocessing and retrying scenarios and simplifies the process from a maintenance perspective 

Acknowledgement Mode needs to assign value as Manual. It will enable ACK to process the message post successful completion of the flow. So that, the message doesn’t get retried or consumed. 

Once both are configured like above (Circuit Breaker and AMQ Listening Strategy) in our components,  the messages will be reprocessed and retried in a configurable manner. 
In case of Error Scenarios, 
Graphical user interfaceDescription automatically generated with medium confidence 

Based on the configuration on flows, once a failure is present, you can catch the error, and after Error Handling, Nack the message; so that, the message stays on the queue and will be subsequently redelivered.  
Graphical user interface, text, application, emailDescription automatically generated 

You can use Ack the message; so that, the message is removed from the queue in case of success scenarios. 

You can store this ack Token in a variable which can be used for Ack/Nack of the message. 
Graphical user interface, text, applicationDescription automatically generated 


At the application level, Circuit breakers are very useful to handle error scenarios and message reprocessing strategy and monitor the API calls on Anypoint MQ or other queues to notify or acknowledge when error raises. 

Reference Link: 

Error Handling with Anypoint MQ | MuleSoft Blog 

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.