August 15, 2023

cOnException – Docs for ESB 6.x

cOnException

Catches the exceptions defined and triggers certain actions which are then
performed on these exceptions and the message routing.

cOnException Standard properties

These properties are used to configure cOnException running in the Standard Job framework.

The Standard
cOnException component belongs to the Exception Handling family.

Basic settings

Exceptions

Click the plus button to add as many lines as needed in the table
to define the exceptions to be caught.

Set a redelivering tries count

Select this check box to set the maximum redelivering tries in the
Maximum redelivering tries
field.

Non blocking asynchronous behavior

Select this check box to enable asynchronous delayed
redelivery.

For details, go to http://camel.apache.org/exception-clause.html.

Exception behavior

None: select this option to take
no action on the original route.

Handle the exceptions: select
this option to handle exceptions and break out the original
route.

Ignore the exceptions: select
this option to ignore the exceptions and continue routing in the
original route.

Route the original input body instead of the current
body

Select this check box to route the original message instead of the
current message that might be changed during the routing.

Usage

Usage rule

cOnException is used as a separate
component in a Route.

Limitation

 n/a

Scenario: Using cOnException to ignore exceptions and continue message
routing

This scenario applies only to a Talend solution with ESB.

In this scenario, a cOnException component is used to
ignore an IO exception thrown by a Java bean so that the message is successfully routed
to the destination in spite of the exception.

use_case_conexception_1.png

Dropping and linking the components

  1. Drag and drop these components from the Palette onto the workspace: a cOnException component, a cFile component, a cBean
    component, and cProcessor component.
  2. Link cFile to cBean using a Row >
    Route connection.
  3. Link cBean to cProcessor using a Row >
    Route connection.
  4. Label the components to better identify their roles in the Route.

Configuring the components

  1. Double-click the cOnException component,
    which is labelled Ignore_exception, to
    open its Basic settings view in the
    Component tab.

    use_case_conexception_2.png

  2. Click the plus button to add a line in the Exceptions table, and define the exception to catch. In this
    example, enter java.io.IOException to handle IO
    exceptions.

    In the Exception behavior area, select
    the Ignore the exceptions option to ignore
    exceptions and let message routing continue. Leave the other parameters as
    they are.
  3. Double-click the cFile component, which
    is labelled Source, to open its Basic settings view in the Component tab.

    use_case_conexception_3.png

  4. In the Path field, enter the path of the
    message source, and leave the other parameters as they are.
  5. Double-click the cBean component, which
    is labelled Throw_exception, to open its
    Basic settings view in the Component tab.

    use_case_conexception_4.png

  6. Select New Instance and in the Bean class field, enter the name of the bean to
    throw an IO exception, beans.throwIOException.class in this scenario.

    Note that this bean has already been defined in the Code node of the Repository
    and it looks like
    this:
    For more information about creating and using Java Beans, see

    Talend Studio User Guide
    .
  7. Double-click the cProcessor component,
    which is labelled Monitor, to open its
    Basic settings view in the Component tab.

    use_case_conexception_5.png

  8. In the Code area, customize the code to
    display the file name of the consumed message on the Run console:

  9. Press Ctrl+S to save your Route.

Viewing code and executing the Route

  1. Click the Code tab at the bottom of the
    design workspace to check the generated code.

    use_case_conexception_6.png

    As shown above, Ignore_exception handles any IO exception
    thrown by .bean(beans.throwIOException.class) invoked by
    cBean_1, so that messages from the endpoint
    Source can be successfully routed onwards
    (continued(true)) in spite of the exception.
  2. Press F6 to execute the Route.

    The route gets executed successfully and the files from the source are
    successfully routed to the destination.
    use_case_conexception_7.png

  3. Change the exception handling option in the cOnException component or deactivate the component and run
    the Route again.

    The exception thrown by the Java bean prevents the messages from being
    routed successfully.

Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x