Handling database failures in a Select transform

You can configure a Failure transform for each Select transform that you define in a message map to handle explicitly SQL database exceptions. By default, the Mapping node throws database exceptions that can be handled by other nodes in the message flow.

Before you begin

Configure the Select transform in a message map. For more information, see Configuring the Select transform in a message map.

About this task

By default, the Mapping node throws database exceptions that the SOAPInput node catches and automatically uses to build a SOAP fault to return to the client.

In the scenario, you use an optional Failure transform to process the first SQL exception that might be thrown from the Select transform database transaction. You build a SOAPFault to include the database exception detail and the Name and Country elements used for the search of an address which failed.

A Failure transform has a nested map. This nested map is where you transform the input and output elements of the Message Assembly to define how to handle failure.

Procedure

To configure the Failure transform in the scenario, complete the following steps:

  1. Right-click Select, and then select Database > Handle Failure.

    The following figure shows the graphically the path choices to add a Failure transform to a Select transform:

    This figure shows the graphically the path choices to add a Failure transform to a Select transform. Select Database, and then Handle Failure.

    A Failure transform is added to the Select transform.

    This figure shows the Failure transform associated with the Select transform.

  2. Connect the message assembly element Name to the Failure transform.

    The following figure shows the element Name connected to the Failure transform:

    This figure shows the element Name connected to the Failure transform.

  3. Connect the message assembly element Country to the Failure transform.

    The following figure shows the element Country connected to the Failure transform:

    This figure shows the element Country connected to the Failure transform

  4. Connect the Failure transform to the output element Fault.

    This figure shows the Failure transform connected to the output Fault section in the output message assembly.

  5. Select Failure.

    The Failure transform nested map opens.

    This figure shows the Failure transform nested map before any transforms are defined.

  6. Define the transforms between the input elements and the message assembly output elements inside the nested map. Complete the following steps:
    1. Connect the input element Name to the output element Name in the message assembly body section Fault with a Move transform.
    2. Connect the input element Country to the output element Country in the message assembly body section Fault with a Move transform.
    3. Connect the database exception element Message to the output element value in the message assembly body section Fault with a Move transform.

  7. Set the cardinality index for the database element Message to 1 in the Properties tab of the Move transform.

    The following figure shows the Properties tab of the Move transform for the element CITY:

    This figure shows the Properties tab of the Move transform for the element Message.

Results

You have successfully completed the development steps of the scenario.

Configure the JDBC connection at run time. For more information, see Configuring a database to be available at run time.