July 30, 2023

cRecipientList – Docs for ESB ESB 7.x

cRecipientList

Routes messages to a number of dynamically specified recipients.

cRecipientList can also process the message before
sending it to the recipients and assemble the replies from the sub-messages into a
single outgoing message.

cRecipientList Standard properties

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

The Standard
cRecipientList component belongs to the Routing family.

Basic settings

Language

Select the expression language from None, Bean, Constant, CorrelationID, EL,
Groovy, Header, JavaScript,
JoSQL, JSonPath, JXPath,
MVEL, OGNL, PHP, Property, Python, Ruby, Simple, SpEL, SQL, XPath, and XQuery.

For more information about how to use the languages to create an expression, see
the site http://camel.apache.org/languages.html.

Expression

Type in the expression that returns multiple endpoints.

Use Result Class Type This option appears when XPath is selected in the Language list. Select this check box to set the result
type of the sub-messages in the field that appears.
Add Namespaces

This option appears when XPath is
selected in the Language list.

Select this check box to add namespaces for the Xpath expression.
Click [+] to add as many namespaces
as required to the table and define the prefix and URI in the
corresponding columns.

Use Delimiter Select this check box to customize the separator for the
Expression. Enter the characters,
strings or regular expressions to be used as the separator in the
Delimiter field.
Use Strategy Select this check box to refer to an aggregation
strategy to assemble the replies from the sub-messages into a single
outgoing message from the recipient list. Enter the ID of the
aggregation strategy in the field.

Parallel Processing

Select this check box to send the message to the recipients
simultaneously.

Use
ExecutorService
This option appears when Parallel
Processing
is enabled. Select this check box to use a
custom thread pool for parallel processing. Specify the thread pool in
the ExecutorService field.

Stop On Exception

Select this check box to stop processing immediately when an
exception occurred.

Ignore Invalid Endpoints

Select this check box to ignore invalid endpoints.

Streaming Select this check box to process the sub-message replies
in the order that the replies are received from each recipient. If this
option is disabled, the replies will be processed in the same order as
specified by the Expression.
Timeout Specify a total timeout in millisecond. If the message
is not routed to the recipients and processed within the given time
frame, the timeout triggers and the recipient list breaks out.
Use On-Prepare Processor Select this check box to use a custom processor to
prepare the copy of the exchange that each recipient will receive. Enter
the ID of the processor in the next field. You can use the cBeanRegister to register a Java bean as a
processor.
Share Unit of Work Select this check box to share the unit of work between
the parent exchange and each recipient exchange. See the same option of
cSplitter for more
information.

Usage

Usage rule

cRecipientList is used as a
middle component in a Route.

Limitation

 n/a

Routing a message to multiple recipients

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

In this scenario, a cRecipientList component is used
to route a message to a list of recipients.

cRecipientList_1.png

To build the Route, do the following.

Dropping and linking the components

  1. Drag and drop the components from the Palette onto the workspace: cFile, cSetHeader,
    cRecipientList, two cMessagingEndpoint and two cProcessor. Change the label of the cFile component to Read_Input. Change the labels of the two cMessagingEndpoint components to Recipient_A and Recipient_B. Change the labels of the two cProcessor components to Print_File_Name_A and Print_File_Name_B.
  2. Link Read_Input to cSetHeader using a Row >
    Route connection.
  3. Link cSetHeader to cRecipientList using a Row
    > Route connection.
  4. Link Recipient_A to Print_File_Name_A using a Row > Route
    connection.
  5. Link Recipient_B to Print_File_Name_B using a Row > Route
    connection.

Configuring the components

  1. Double-click cFile to open its Basic settings view in the Component tab.

    cRecipientList_2.png

  2. In the Path field, type in the path to
    the source message, for example, “E:/data/input”. Keep other default settings
    unchanged.
  3. Double-click cSetHeader to open its
    Basic settings view in the Component tab.

    cRecipientList_3.png

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

    In the Name field, enter the header name,
    for example, “ListOfRecipients”.
    In the Language list, select Constant.
    In the Value field, enter the endpoint
    URIs, for example, “direct:a,direct:b”.
  5. Double-click cRecipientList to open its
    Basic settings view in the Component tab.

    cRecipientList_4.png

  6. In the Language list, select Header.

    In the Expression field, enter the name
    of the header that contains the recipients list, that is, “ListOfRecipients”.
  7. Double-click Recipient_A to open its
    Basic settings view in the Component tab and define the URI of recipient
    A.

    cRecipientList_5.png

    Perform the same operation to Recipient_B to define the URI of recipient B.

  8. Double-click Print_File_Name_A to open
    its Basic settings view in the Component tab and enter the code below to print
    out the message received by Recipient_A.System.out.println("Recipient_a just downloaded:"+exchange.getIn().getHeader("CamelFileName"));

    cRecipientList_6.png

    Perform the same operation to Print_File_Name_B and type in the code below in its code
    box:
  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.

    cRecipientList_7.png

    As shown above, the route gets the message from
    Read_Input_cFile_1, and
    .setHeader("ListOfRecipients") using
    .constant("direct:a,direct:b"). Then,
    cRecipientList_1 reads
    .header("ListOfRecipients") and routes the message to the
    recipients included in it.
  2. Press F6 to execute the Route.

    The message is sent to recipients included in the header.
    cRecipientList_8.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