TryCatch node

This topic contains the following sections:

Purpose

Use the TryCatch node to provide a special handler for exception processing. Initially the input message is routed on the try terminal of this node, which you must connect to the remaining non-error processing nodes of the message flow. If a downstream node (which can be a Throw node) throws an exception, the TryCatch node catches it and routes the original message to its catch terminal. Connect the catch terminal to further nodes to provide error processing for the message after an exception.

In this way, exceptions are stopping the message flow processing, and from affecting any transaction in progress. If the catch output terminal is connected, the message is propagated to it. If the catch terminal is not connected, the message is discarded.

The TryCatch node is represented in the workbench by the following icon:

TryCatch node icon

Using this node in a message flow

Look at the following sample to see how you can use this node:

Use the Throw and TryCatch nodes when you are use the Compute node to calculate a total. You can create a message that is sent to your system administrator when the total calculated exceeds the maximum value for the Total field.

Configuring the TryCatch node

When you have put an instance of the TryCatch node into a message flow, you can configure it.

To do this, right-click the node in the editor view and click Properties. The Description properties are displayed.

Enter a short description, a long description, or both.

Click Apply to make the changes to the TryCatch node without closing the properties dialog, or click OK to apply the changes and close the properties dialog.

Click Cancel to close the dialog and discard all the changes that you have made to the properties.

Now you must connect the node's terminals to determine how it operates within this message flow.

Connecting the terminals

The TryCatch node has no configurable properties that affect its operation. You determine how it operates by connecting the output terminals to subsequent nodes in your message flow.

  1. Connect the try terminal to the first node in the sequence of nodes that provides the normal (non-error) phase of processing of this message. This can be a sequence of one or more nodes that perform any valid processing. It can conclude with an output node, but does not have to.
  2. Connect the catch terminal to the first node in the sequence of nodes that provides the error processing for this message flow. This can be a sequence of one or more nodes that perform any valid processing. It can conclude with an output node, but does not have to.

    When an exception is thrown in the message flow, either by the explicit use of the Throw node or the ESQL THROW statement, or by the broker raising an implicit exception when it detects an error that the message flow is not programmed to handle, control returns to the TryCatch node.

    The message is propagated through the catch terminal and the error handling that you have designed is executed. The message that is propagated through this terminal has the content that it had at the point at which the exception was thrown, including the full description of the exception in the ExceptionList.

Terminals and properties

The TryCatch node terminals are described in the following table.

Terminal Description
In The input terminal that accepts a message for processing by the node.
Catch The output terminal to which the message is propagated if an exception is thrown downstream and caught by this node.
Try The output terminal to which the message is propagated if it is not caught.

The following table describes the node properties; the column headed M indicates whether the property is mandatory (marked with an asterisk on the properties dialog if you must enter a value when no default is defined), the column headed C indicates whether the property is configurable (you can change the value when you add the message flow to the bar file to deploy it).

The TryCatch node Description properties are described in the following table.

Property M C Default Description
Short Description No No   A brief description of the node.
Long Description No No   Text that describes the purpose of the node in the message flow.