July 30, 2023

cDynamicRouter – Docs for ESB ESB 7.x

cDynamicRouter

Routes a message or messages to different endpoints on specified
conditions.

cDynamicRouter Standard properties

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

The Standard
cDynamicRouter component belongs to the Routing family.

Basic settings

Bean class

Enter the name of the bean class to be used for the dynamic
router.

Specify the method

Select this check box to specify the method to be
used which is defined in the bean class.

Ignore Invalid Endpoints

Select this check box to ignore unresolved
endpoint URIs. Clear the check box to throw an exception when
endpoint URIs are not valid.

Usage

Usage rule

cDynamicRouter is used as a
middle or end component in a Route.

Limitation

 n/a

Routing files conditionally to different file paths

This scenario applies only to Talend Open Studio for ESB, Talend Data Services Platform and Talend Data Fabric.

In this scenario, three file messages containing people information are routed to
different endpoints according to the city names they contain.

The following is an extract of the example XML files used in this use case:

Message_1.xml:

Message_2.xml:

Message_3.xml:

A predefined Java bean, setDynaURI, is called in this use case to
return endpoint URIs according to the city name contained in each message, so that the
message containing the city name Washington will be routed to
endpoint Washington and so forth.

For more information about creating and using Java Beans, see
Talend Studio User
Guide
.

Dropping and linking the components

cDynamicRouter_1.png

  1. From the Palette, expand the Connectivity folder, and drop one cFile and three cMessagingEndpoint components onto the design workspace.
  2. Expand the Routing folder, and drop a
    cDynamicRouter component onto the
    design workspace.
  3. Expand the Custom folder, and drop three cProcessor components onto the design
    workspace.
  4. Label the components for better identification of their respective
    functionality.
  5. Right-click the cFile component, select
    Row > Route from the contextual menu and click the cDynamicRouter component.
  6. Repeat this operation to connect the cMessagingEndpoint components to the cProcessor components.

Configuring the components and connections

  1. Double-click the input cFile component to
    display its Basic settings view in the
    Component tab and set its properties.

    In this use case, simply specify the input file path and leave the other
    parameters as they are.
    cDynamicRouter_2.png

  2. Double-click the cDynamicRouter component
    to display its Basic settings view in the
    Component tab.
  3. In the Bean class field, type in the name
    of the predefined Java bean. Leave the Specify the
    method
    check box unselected as there is only one method in
    the Java bean and leave the Ignore Invalid
    Endpoints
    check box unselected if you want the component to
    throw an exception when endpoint URIs are not valid.

    cDynamicRouter_3.png

  4. Double-click the first cMessagingEndpoint
    component, which is labelled Washington,
    to display its Basic settings view in the
    Component tab, and type in the URI in
    the URI field for the destination of your
    message.

    Here, we want to use this component to retrieve the message routed to the
    URI direct:Washington, as shown below.
    cDynamicRouter_4.png

  5. Repeat this step to set the endpoint URIs for the other two cMessagingEndpoint components:
    direct:London and
    direct:Beijing respectively.
  6. Double-click the first cProcessor component, which is labelled Monitor_Washington, to display its Basic
    settings
    view in the Component
    tab.

    cDynamicRouter_5.png

  7. In the Code box, customize the code to
    display the file name of the message routed to the endpoint Washington on the console.

  8. Repeat these steps to configure the other two cProcessor components to display the file names of the
    messages routed to the endpoints London and
    Beijing respectively.
  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 have a look at the generated code.

    cDynamicRouter_6.png

    As shown in the code, the incoming message from the endpoint
    Message_source is routed by .dynamicRouter to
    endpoints the URIs of which are dynamically set according to
    beans.setDynaURI.class.
  2. Click the Run view to display it and
    click the Run button to launch the
    execution of your Route.

    You can also press F6 to execute it.
    RESULT: The source messages are routed to different endpoints based on the
    city names contained in the messages.
    cDynamicRouter_7.png


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