First there is a similar unanswered question Joining routes into single aggregator
We have some consumer routes (ftp, file, smb) reading files from remote systems.
You almost have it working. Here is the change you need (and after I will explain).
from("direct:aggregate").id("aggregate")
.aggregate(property(AGGREGATION_PROPERTY), new BodyInAggregationStrategy())
.completionSize(property(Exchange.BATCH_SIZE))
.to("log:result", "mock:result")
The result will be:
Exchange received, body: A+A+A
Exchange received, body: B+B
Exchange received, body: A
Note: You won't receive a result for the "Z"
since the batch size is 7
.
To explain - as you have read, the Aggregator is a versatile camel component and the key things to define correctly are:
Now in your case you are aggregating on a property AGGREGATION_PROPERTY
which will be A
, B
or Z
. In addition you are specifying a batch size.
However you aren't expressing a completionSize()
in your route. Instead you were using completionFromBatchConsumer
- which does something different (the code states that it looks for a Exchange#BATCH_COMPLETE
property), thus the weird results.
Anyway, .completionSize(Exchange.BATCH_SIZE)
will make your test run as desired.
Good luck further.