Contact Us 1-800-596-4880

Try Scope XML Reference

Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule reached its End of Life on November 2, 2022, when Extended Support ended.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

A Try scope follows the structure described below.

  • A single root element <try>

  • Components that are executed under the error-handling rules defined by the Try scope are defined as child elements of the try element. You can place one or many here.

  • A single <error-handler> element holds all error handling strategies for the scope.

  • In the error handler, one or several on-error-continue and on-error-propagate define the various strategies. At least one of these must be present.

  • Components that are executed when a matching error occurs are defined as child elements of the on-error element. You can place one or many here.

<try>
  <!-- COMPONENTS TO TRY TO USE -->
  <error-handler>
    <on-error-continue>
      <!-- COMPONENTS TO USE IN CASE OF ERROR -->
    </on-error-continue>
    <on-error-propagate>
      <!-- COMPONENTS TO USE IN CASE OF ERROR -->
    </on-error-propagate>
  </error-handler>
</try>

Each error handling strategy in a Try scope (on-error-*) follows a condition. This condition is typically an error type (or a list of several) which must match the current error. You can also define this condition as a freely written expression, such as error.cause.message.contains("fatal").

Note that conditions are evaluated in order and only the first strategy to match is executed.

Below is an example that includes two error handling strategies, each executing a logger component:

<try>
  <http:request config-ref="HTTP-config" method="GET" path="/" />
  <error-handler>
    <on-error-continue enableNotifications="true" logException="true" type="CONNECTIVITY">
      <logger level="INFO" doc:name="Logger" message="Connectivity Error"/>
    </on-error-continue>
    <on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" type="EXPRESSION">
      <logger level="INFO" doc:name="Logger" message="Expression error" />
    </on-error-propagate>
  </error-handler>
</try>

Properties of Try

Property Default Description

transactionalAction

INDIFFERENT

Defines if what’s in the scope is treated as a transaction. Possible values:

  • INDIFFERENT : What’s in the scope isn’t treated as a transaction.

  • ALWAYS_BEGIN: A new transaction is started every time the scope is executed.

  • BEGIN_OR_JOIN: If the current processing of the flow has already begun a transaction, join it. Otherwise, begin a new one. (Only relevant when execution order may vary).

transactionalType

LOCAL

Defines the type of transaction to use. Possible values:

  • "LOCAL"

  • "XA"