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, For more information about how to use the languages to create an expression, see |
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 Select this check box to add namespaces for the Xpath expression. |
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 |
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 |
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 |
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.
To build the Route, do the following.
Dropping and linking the components
-
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. -
Link Read_Input to cSetHeader using a Row >
Route connection. -
Link cSetHeader to cRecipientList using a Row
> Route connection. -
Link Recipient_A to Print_File_Name_A using a Row > Route
connection. -
Link Recipient_B to Print_File_Name_B using a Row > Route
connection.
Configuring the components
-
Double-click cFile to open its Basic settings view in the Component tab.
-
In the Path field, type in the path to
the source message, for example, “E:/data/input”. Keep other default settings
unchanged. -
Double-click cSetHeader to open its
Basic settings view in the Component tab. -
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”. -
Double-click cRecipientList to open its
Basic settings view in the Component tab. -
In the Language list, select Header.
In the Expression field, enter the name
of the header that contains the recipients list, that is, “ListOfRecipients”. -
Double-click Recipient_A to open its
Basic settings view in the Component tab and define the URI of recipient
A.Perform the same operation to Recipient_B to define the URI of recipient B.
-
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"));
Perform the same operation to Print_File_Name_B and type in the code below in its code
box:1System.out.println("Recipient_b just downloaded:"+exchange.getIn().getHeader("CamelFileName")); - Press Ctrl+S to save your Route.
Viewing code and executing the Route
-
Click the Code tab at the bottom of the
design workspace to check the generated code.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. -
Press F6 to execute the Route.
The message is sent to recipients included in the header.