-
Double-click the cFile component labeled
Sender to display its Basic settings view in the Component tab.
-
In the Path field, fill in or browse to
the path to the folder that holds the source files.
From the Encoding list, select the
encoding type of your source files.
In the FileName field, type in the file
name of the source message. You can skip this step if the source folder
contains only one file.
-
Repeat steps 1 and 2 above to define the output file path and encoding
type in the Basic settings view of the
other cFile component, which is labeled
Receiver. Leave the FileName field blank.
-
Double-click the cSplitter component to
display its Basic settings view in the
Component tab.
In this use case, as we want to split the message into sub-messages at
each person node of the XML file. Select XPath in the Language list and type in "/people/person") in
the Expression field.
-
Double-click the cSetHeader component,
which is labeled Set_file_name to display
its Basic settings view in the Component tab.
-
Click [+] to add a row to the Headers table.
In the Name field, type in the name of
the header you want to give to the messages.
Here, as we want to define the file name for each incoming message, fill
in "CamelFileName" as the header name.
Select Bean in the Language field and type in the name of the predefined Java
Bean in the Value field,
beans.setFileNames.class in this use case.
-
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 each message routed to
the receiving endpoint, so we customize the code as follows:
System.out.println("File received: "+
exchange.getIn().getHeader("CamelFileName"));
-
Press Ctrl+S to save your Route.