You can use completionSize
and completionInterval
together and add a completionPredicate
to the equation, like this (you do need to use eagerCheckCompletion="true"
because we need to test the incoming message, not the aggregated message):
<route>
<from uri="direct:aggregator" />
<aggregate completionSize="500" completionInterval="60000" eagerCheckCompletion="true">
<correlationExpression>
<xpath>/fizz/buzz</xpath>
</correlationExpression>
<completion-predicate>
<simple>${property.fireNow} == 'true'</simple>
</completion-predicate>
<to uri="bean:postProcessor?method=run" />
</aggregate>
</route>
An alternative could be to create a compound predicate that tests all three conditions and use only that predicate as completion-predicate
but this solution is inferior because the interval timeout is triggered by a separate thread, whereas using a compound predicate there is no thread to trigger the aggregation on timeout expiration.