Configuring the components and connections - 7.3

SetBody (Mediation)

Version
7.3
Language
English
Product
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Data Governance > Third-party systems > Processing components (Mediation) > SetBody components (Mediation)
Data Quality and Preparation > Third-party systems > Processing components (Mediation) > SetBody components (Mediation)
Design and Development > Third-party systems > Processing components (Mediation) > SetBody components (Mediation)
Last publication date
2023-06-12

Procedure

  1. Double-click the cFile component labeled Sender to display its Basic settings view in the Component tab.
  2. In the Path field, fill in or browse to the path to the folder that holds the source files.
  3. From the Encoding list, select the encoding type of your source files. Leave the other parameters as they are.
  4. Repeat these steps to define output file path and encoding type in the Basic settings view of the other cFile component, which is labeled Receiver.
  5. Double-click the cSetBody component to display its Basic settings view in the Component tab.
  6. From the Language list box, select the language of the expression you are going to use.
    Here we are handling XML files, so select XPath from the list box.
  7. In the Expression field, type in the expression that will return the new message content you want.
    In this use case, we want person to be the root element of each file when routed to the receiving endpoint, so type in "/people/person" in the Expression field.
  8. Double-click the cProcessor component 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.
    In this use case, we want to display the file name and content of each message routed to the receiving endpoint, so we customize the code as follows:
    System.out.println("File received: " +
    exchange.getIn().getHeader("CamelFileName") + 
    "\nContent:\n " + 
    exchange.getIn().getBody(String.class));
  9. Press Ctrl+S to save your Route.