July 30, 2023

cRoutingSlip – Docs for ESB ESB 7.x

cRoutingSlip

Routes the message consecutively through a series of processing steps, with the
sequence of steps unknown at design time and variable for each message.

cRoutingSlip Standard properties

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

The Standard
cRoutingSlip component belongs to the Routing family.

Basic settings

Header name

Type in name of the message header as defined in the preceding
cSetHeader component,
mySlip by default. The header should carry
a list of endpoint URIs you wish each message to be routed
to.

URI delimiter Delimiter used to separate multiple endpoint URIs
carried in the message header, comma (,) by default.

Usage

Usage rule

cRoutingSlip is used as a middle
or end component of a sub-route. It always follows a cSetHeader component, which sets a header
to each message to carry a list of endpoint URIs.

Routing a message consecutively to a series of endpoints

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

In this scenario, messages from a file system is routed consecutively to a series of
endpoints according to the URIs carried in the message header.

Dropping and linking the components

This use case requires a cFile component as the
message sender, a cSetHeader component to define a
series of endpoints, a cRoutingSlip component to
route messages to the endpoints consecutively, three cMessagingEndpoint components to retrieve messages routed to the
endpoints, and three cProcessor components to
monitor messages routed to the connected messaging endpoints.

cRoutingSlip_1.png

  1. From the Palette, expand the Connectivity folder, drop one cFile and three cMessagingEndpoint components onto the design workspace, and
    label them to better identify their roles in the Route, as shown
    above.
  2. From the Core folder, drop a cSetHeader component onto the design workspace, and label it
    to better identify its role in the Route.
  3. From the Routing folder, drop a cRoutingSlip component onto the design workspace,
    and label it to better identify its role in the Route.
  4. From the Custom folder, drop three cProcessor components onto the design workspace, and label
    them to better identify their roles in the Route.
  5. Right-click the cFile component, select
    Row > Route from the contextual menu and click the cSetHeader component.
  6. Right-click the cSetHeader component,
    select Row > Route from the contextual menu and click the cRoutingSlip component.
  7. Repeat this operation to connect the cMessagingEndpoint components to the corresponding cProcessor components.

Configuring the components and connections

  1. Double-click the cFile component, which
    is labelled Sender, to display its Basic settings view in the Component tab.

    cRoutingSlip_2.png

  2. In the Path field, fill in or browse to the path to the
    folder that holds the source files Beijing.xml, London.xml,
    Paris.xml, and Washington.xml.

    From the Encoding list, select the
    encoding type of your source files. Leave the other parameters as they
    are.
  3. Double-click the cSetHeader component,
    which is labelled Set_endpoints, to
    display its Basic settings view in the
    Component tab.

    cRoutingSlip_3.png

  4. Click [+] to add a row to the Headers table.

    In the Name field, type in the name of
    the header you want to add to each message.
    In this use case, we simply use mySlip, which is the
    default value filled in the Header name
    field of the cRoutingSlip component.
  5. From the Language list box, select the Constant or Simple, and in the Value
    field, type in the URIs you wish the message to be routed consecutively to,
    separated by a comma, which is the default value of the URI delimiter field of the cRoutingSlip component.

    In this use case, we want the message to be routed first to endpoint
    c, then to endpoint a, and
    finally to endpoint b.
  6. Double-click the cRoutingSlip component,
    which is labelled Routing_slip, to
    display its Basic settings view in the
    Component tab, and define the message
    header in the Header name field and the URI
    delimiter in the URI delimiter field.

    In this use case, we simply use the default settings.
    cRoutingSlip_4.png

  7. Double-click the cMessagingEndpoint
    component labelled Endpoint_a to display its Basic settings view in the Component tab, and type in the URI in the URI field for the destination of your messages.

    Here, we want to use this component to retrieve the message routed to the
    URI direct:a.
    cRoutingSlip_5.png

    Repeat this step to set the endpoint URIs in the other cMessagingEndpoint components:
    direct:b and direct:c
    respectively.
  8. Double-click the cProcessor component,
    which is labelled Monitor_a, to display
    its Basic settings view in the Component tab, and customize the code so that the
    console will display information the way you wish.

    Here, we want to use this component to monitor the messages routed to the
    connected endpoint a and display the file name, so we
    customize the code accordingly, as follows:
    Repeat this step to customize the code for the other two cProcessor components, for messages routed to the
    connected endpoints b and c
    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.

    cRoutingSlip_6.png

    In this partially shown code, messages from the sender are given a header
    according to .setHeader, which carries a list of URIs
    ("direct:c,direct:a,direct:b"), and then routed in the slip
    pattern according by cRoutingSlip_1.
  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.
    cRoutingSlip_7.png

    RESULT: The source file messages are routed consecutively to the defined
    endpoints: c, then a, and then
    b.

Routing each message conditionally to a series of endpoints

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

In this scenario, which is based on the previous scenario, each message from a file
system is routed consecutively to different endpoints according to the city name it
contains.

All files used in this use case are named after the city name they contain. The
following are the extracts of two examples:

Beijing.xml:

Paris.xml:

A predefined Java Bean, setEndpoints, is called in this use case
to return endpoint URIs according to the city name contained in each message, so that
the messages will be routed as follows:

  • The message containing the city name Paris will be routed
    first to endpoint a, then to endpoint
    b, and finally to endpoint c.

  • The message containing the city name Beijing will be
    routed first to endpoint c, then to endpoint
    a, and finally to endpoint b.

  • Any other messages will be routed to endpoint b and then
    to endpoint c.

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

Dropping and linking the components

In this scenario, we will reuse the Route set up in the previous scenario, without
adding or removing any components or modifying any connections.

Configuring the components and connections

In this scenario, we only need to configure the cSetHeader component to call the predefined Java Bean, and keep the
settings of all the other components are they are in the previous scenario.

  1. Double-click the cSetHeader component to
    display its Basic settings view in the
    Component tab.

    cRoutingSlip_8.png

  2. Select Bean from the Language list box, and in the Value field, specify the Java Bean that will return the
    endpoint URIs. In this use case, type in:

    beans.setEndpoints
  3. 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.

    cRoutingSlip_9.png

    In this partially shown code, messages from the sender are given a header
    according to .setHeader, which carries a list of URIs returned
    by the beans.setEndpoints.class, and then routed to the
    cRoutingSlip_1.
  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.
    cRoutingSlip_10.png

    RESULT: The sources are routed consecutively to the defined endpoints: the
    message containing the city name Beijing is routed
    first to endpoint c, then to endpoint
    a, and finally to endpoint b;
    the message containing the city name Paris is routed
    first to endpoint a, then to endpoint
    b, and finally to endpoint c;
    the other messages are routed to endpoint b and then to
    endpoint c.

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