Procedure
-
Double-click the cFile component,
which is labelled File_source, to display its Basic settings view in the Component tab.
-
In the Path field, browse to or enter the
input file path, and leave the other parameters as they are.
In this scenario, there are four text files in the specified directory: a.txt, b.txt, c.txt and d.txt, the contents of which are
This is a!
,This is b!
,This is c!
, andThis is d!
respectively. -
Double-click the cAggregate
component, which is labelled Aggregator, to display its
Basic settings view in the Component tab.
-
In the Language field, select Constant or Simple as the expression language.
In the Expression field, enter the expression "getBody(String.class)" to retrieve the body of the message.In the Strategy field, enter the name of the Java bean AggregateBody you just created.Select the Number of messages check box and type in 2 in the field.
-
Double-click the cProcessor
component labelled Monitor_before to display its Basic settings view in the Component tab.
-
In the Code box, customize the code as
follows so that the Run console displays
the message contents before an aggregation takes place:
System.out.println("Before aggregation: "+ exchange.getIn().getBody(String.class));
-
In the same way, configure the cProcessor component labelled Monitor_after so
that the Run console displays the message contents after an aggregation takes place:
System.out.println("After aggregation: "+ exchange.getIn().getBody(String.class));
- Press Ctrl+S to save your Route.