DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • MDC Logging With MuleSoft Runtime 4.4
  • MuleSoft Integration With RabbitMQ
  • How to Use Mulesoft VM Connector
  • Managing Dynamic Application Properties in MuleSoft for CloudHub Applications

Trending

  • Rethinking Java CRUDs With Event Sourcing and CQRS Patterns
  • Microservices: Externalized Configuration
  • How to Parse Large XML Files in PHP Without Running Out of Memory
  • Spring AI Advisors: Chat Memory, Token Tracking, and Message Logging
  1. DZone
  2. Data Engineering
  3. Databases
  4. Types of Exception Strategies in MuleSoft Anypoint Studio

Types of Exception Strategies in MuleSoft Anypoint Studio

Whether it's catch exception strategies or rollback exception strategies, MuleSoft Anypoint Studio offers tons of different types of messaging exceptions.

By 
Jitendra Bafna user avatar
Jitendra Bafna
·
Updated May. 10, 17 · Opinion
Likes (8)
Comment
Save
Tweet
Share
27.5K Views

Join the DZone community and get the full member experience.

Join For Free

MuleSoft provides various ways to handle exceptions. Faults in Mule are generally referred to as exceptions. Mule exceptions can be divided into two categories:

  1. System exceptions are generally invoked when the exception is thrown at system level (i.e., when no message is invoked). This type of error occurs during application startup when there is a connection failure with external systems — i.e., let's say Mule is trying to establish a connection with a JDBC database to fetch and read messages. If the connection fails, Mule invokes the system exception strategy.

  2. Messaging exceptions are generally invoked when the messaging exception strategy is thrown into the flow.

We will focus on messaging exceptions in this article. Mule provides various exception strategies.

Catch Exception Strategy

The catch exception strategy catches all of the exceptions within the parent flow and processes them, overriding the default exception strategy. Further, you can use the catch exception strategy to:

  • Avoid propagating exceptions to inbound connectors.

  • Avoid propagating exceptions to parents via flow reference components.

  • Ensure that the transaction processed by the flow will not roll back when the error occurs.

Image title

Reference Exception Strategy

You can create one or more global exception strategies in your Mule application to reuse in your flows. First, create a global exception strategy, then add a reference strategy exception to the flow to apply the error-handling behavior of your new global catch exception strategy.

Image title

Choice Exception Strategy

You can define the choice exception strategy to customize how Mule handles the message that throws the exception based on the message's exception type at the moment it throws the exception.Image title

  • Choice exception strategy contains one or more exception or rollback strategies.

  • Choice exception strategy cannot be nested with other choice exception strategies.

  • Any Mule expression evaluator can be used as the expression attribute of an exception strategy.

Rollback Exception Strategy

You can define the rollback exception strategy to ensure that the message throws an error in the flow that can be rolled back for re-processing.

Rollback exception strategy can potentially create an infinite loop during message failure. The rollback exception strategy catches the error and rolls the message for reprocessing; the message throws error again; the rollback exception strategy rolls the message again for reprocessing; and so on.

To avoid this infinite loop and responsibly manage unresolvable errors, you can apply two limitations to a rollback exception strategy:

  1. Define the maximum number of times that the rollback exception strategy attempts to redeliver the message for processing.

  2. Define a flow to handle messages that exceed the maximum number of redelivery attempts.

There are various ways to define the messaging exception strategy within a Mule application.

Define Error Handler Within Mule flow

You can define the exception strategy within a flow and it will not be referenced by other flows within the Mule application.

Define Global Error Handler

You can define a global error handler that can be referenced from any flow (except sub-flows, which inherit the calling flow error handler) using reference flow strategy.

Define Custom Default Global Error Handler

You can define custom default global error handlers that will become the default error handler for your flows within the Mule application unless one of the above options is used in the flow.

I hope that this article on exception strategies using MuleSoft Anypoint Studio is helpful!

Here is the video tutorial.


Flow (web browser) MuleSoft Rollback (data management) application Connection (dance) Database Moment Fault (technology) Connector (mathematics)

Opinions expressed by DZone contributors are their own.

Related

  • MDC Logging With MuleSoft Runtime 4.4
  • MuleSoft Integration With RabbitMQ
  • How to Use Mulesoft VM Connector
  • Managing Dynamic Application Properties in MuleSoft for CloudHub Applications

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook