concept exception strategy in category mule

This is an excerpt from Manning's book Mule in Action, Second Edition.
So what does a private flow look like? Basically it’s just a regular flow, but without any message source. To illustrate this, let’s revisit the subflow used by Prancing Donkey to transform messages from an old format to a new one (see listing 2.4). It happened that for a small subset of messages, the transformation was failing; they then decided to configure an exception strategy local to the transformation in order to send failed messages to a JMS queue for later analysis and reprocessing. For this, they had to convert their subflow into a private flow as shown in the next listing.
In the first half of this chapter, we’ll examine how Mule implements exception handling. We’ll first consider the reconnection strategies to deal with problems related to connections, and then we’ll explore exception strategies, in which you’ll see how Mule lets you react when errors arise with a message involved.
Being able to define different reactions for system exceptions caused by connection problems and for messaging exceptions lets you handle each sort of error independently. You learned how you can react to connection problems; now let’s find out how exception strategies work for situations where there are exceptions with messages involved.
You have the option of explicitly defining exception strategies in multiple places in your Mule configurations. Exception strategies can be configured on a per-flow basis. This is done by defining an exception strategy at the end of each flow definition. You can additionally define exception strategies globally; in this case, to establish the exception strategy in a flow, you’ll have to use a reference. And finally, you can also configure the default exception strategy that Mule will use when there’s no strategy configured for a flow with a problem.
Let’s start by configuring an exception strategy inside a flow. We still haven’t studied the different built-in exception strategies, but don’t worry; we’ll do so soon. In the meantime, let’s use a catch-exception-strategy that will catch and process all exceptions thrown in the flow, shown in the next listing.
Here you can find one new element, the catch-exception-strategy
. This element instructs the flow to respond with a String that summarizes the exception message, for any kind of error. This approach is useful for special cases, but requires you to configure different exception strategies for flows that could reuse exception strategies. To avoid this, you can use the global exception strategies.
Now that you’re more comfortable with the different ways to configure an exception strategy in Mule, it’s a good moment to learn about the exception strategies Mule supports. As we mentioned before, the default exception strategy will log exceptions and move on. This is often the right degree of action to take, but sometimes you’ll want to take more elaborate measures when an exception occurs. This is particularly true in a large or distributed environment. Equally true in such an environment is the inevitability that a remote service will be unavailable. When such a service is the target of an outbound endpoint, you might want Mule to attempt to deliver the message to a different endpoint or rollback and retry. To suit your needs, Mule provides five exception strategies ready to use:
. This element instructs the flow to respond with a String that summarizes the exception message, for any kind of error. This approach is useful for special cases, but requires you to configure different exception strategies for flows that could reuse exception strategies. To avoid this, you can use the global exception strategies.