July 30, 2023

cSplitter – Docs for ESB ESB 7.x

cSplitter

Splits a message into several sub-messages so that they can be handled and treated
differently in individual routes.

cSplitter Standard properties

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

The Standard
cSplitter component belongs to the Routing family.

Basic settings

Language

Select the language of the expression you want to use to split your messages,
from None, Constant, 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.

Correlation expression/Expression

Type in the expression to use to split the messages.

Correlation expression/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. The default native XML objects
org.w3c.dom.NodeList will be used if not
specified.

Correlation expression/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 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 splitter. Enter the ID of the aggregation
strategy in the Strategy field. The
sub-message replies will be aggregated in the order they come back if
Streaming is enabled. If not, the
sub-message replies will be aggregated in the same order as they were
split.
Parameters/Parallel
Processing
Select this check box to process the sub-messages
concurrently. The caller thread will wait until all sub-messages have
been fully processed before it continues.
Parameters/Stop on
Exception
Select this check box to stop processing immediately
when an exception occurs.
Parameters/Streaming Select this check box to split the message in a
streaming fashion, which means it will split the input message in
chunks. It is recommended to enable this option when processing big
messages.
Parameters/Share Unit of
Work
Select this check box to share the unit of work between
the parent exchange and each split exchange. For more information and an
use case of this option, see the site http://camel.apache.org/splitter.html.
Parameters/Timeout Specify a total timeout in millisecond. If the message
is not split and processed within the given time frame, the timeout
triggers and the splitter breaks out.

Usage

Usage rule

cSplitter is used as a middle
component in a Route.

Connections split: Select this link to route the split
messages to the next endpoint.
Route: Select this link to route all the messages
from the sender to the next endpoint.

Limitation

 n/a

Using cSplitter to split a message and aggregate replies from
sub-messages

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

In this scenario, we will use the cSplitter component
to split a message and aggregate the replies from sub-messages.

A predefined Java Bean, AppendAggregator will be called to as the
strategy to aggregate the replies from sub-messages. For more information about creating
and using Java beans, see
Talend Studio User Guide
.

Dropping and linking the components

cSplitter_1.png

  1. From the Palette, expand the Custom folder. Drag and drop a cBeanRegister component onto the design workspace.
  2. From the Orchestration folder, drag and drop a cTimer components onto the design
    workspace.
  3. From the Core folder, drag and drop two cSetBody and two cDirect components onto the design workspace.
  4. From the Routing folder, drag and drop a
    cSplitter component onto the design
    workspace.
  5. From the Miscellaneous folder, drag and
    drop two cLog components onto the design
    workspace.
  6. Label the components to better identify their roles in the Route as shown
    above.
  7. Right-click the cSplitter component,
    select Row > Split from the contextual menu and click the cDirect component labeled
    directA_sender.
  8. Right-click the cSplitter component
    again, select Row > Route from the contextual menu and click the cLog component labeled
    Log_Finished.
  9. In the same way, link the other components in the Route using the
    Row > Route connection as shown above.

Configuring the components and connections

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

    cSplitter_2.png

  2. In the Id field, enter
    "appendAggregator". Select the Simple option and in the Class
    Name
    field, enter the name of the predefined Java bean,
    beans.AppendAggregator in this scenario, which will be
    called later by the cSplitter
    component.
  3. Double-click the cTimer component labeled
    Starter to display its Basic settings view in the Component tab.

    cSplitter_3.png

  4. In the Repeat field, enter 1
    to trigger the message exchange. Keep the default settings of the other
    options.
  5. Double-click the cSetbody component
    labeled Set_body to display its Basic settings view in the Component tab.

    cSplitter_4.png

  6. Select SIMPLE in the Language list and enter "thing1, thing2,
    thing3"
    in the Expression field
    as the message body.
  7. Configure the cSetbody component labeled
    Set_new_body in the same way to set
    new body to the sub-messages. In the Expression field, enter *** SPLIT: ${body} to
    add *** SPLIT: before the old message body.

    cSplitter_5.png

  8. Double-click the cSplitter component to
    display its Basic settings view in the
    Component tab.

    cSplitter_6.png

  9. In this use case, we want to split the message body into sub-messages
    using , as the separator.

    Select Simple in the Language list and enter ${body} in
    the Expression field.
    Select the Use Strategy check box. In the
    Strategy field, enter the Id of the
    preregistered Java bean appendAggregator, which will be
    used to aggregate the replies from sub-messages.
  10. Double-click the cDirect component
    labeled directA_sender to display its
    Basic settings view in the Component tab.

    cSplitter_7.png

  11. Click […] and select the directA_receiver node to receive the
    sub-messages.
  12. Double-click the cDirect component
    labeled directA_receiver to display its
    Basic settings view in the Component tab.

    cSplitter_8.png

  13. In the Name field, type in
    "directA" to identify this endpoint.
  14. Keep the default settings of the cLog
    components labeled Log_Finished and
    Log_Split. Log_Finished will
    log the aggregated replies from sub-messages. Log_Split
    will log the sub-messages.
  15. 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.

    cSplitter_9.png

    As shown in the code, the message route is built from one
    endpoint .to another. The message sent to
    cSplitter_1 is split by the method
    .split().simple("${body}") and the replies from the
    sub-messages are aggregated by the method
    .aggregationStrategyRef("appendAggregator").
  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.

    cSplitter_10.png

    RESULT: The source message is split into sub-messages using ,
    as the separator and each sub-message is given a new message body. The
    replies from the sub-messages are aggregated then into a single outgoing
    message from the cSplitter
    component.

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