Aggregation to fire endpoint until predicate is satisfied

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Aggregation to fire endpoint until predicate is satisfied

Michael Joyner
Hi,

Is there a way for the .aggregate to keep firing until predicate is satisfied?
Like this:
from("direct:database-save")
.log("Fetch 500 records until no more ....")
.aggregate(constant(true), batchAggregationStrategy())
.completionPredicate().simple("${body.get('offset')} != -1")
.completionTimeout(BATCH_TIME_OUT)
.execute("direct:fetchBatchFromAPI") <====== LIKE THIS
.log("All records are fetched ....");

I bascially want to avoid looping when the aggregator has a predicate. I just want to ask if there is a method that I don't know about.
Thank you,
Michael Joyner
Reply | Threaded
Open this post in threaded view
|

Re: Aggregation to fire endpoint until predicate is satisfied

Onder SEZGIN
I would suggest reading by size from your data source and use split and
aggregate together to see the end of batch..

On Wed, Sep 12, 2018 at 4:42 PM Michael Joyner <[hidden email]>
wrote:

> Hi,
>
> Is there a way for the .aggregate to keep firing until predicate is
> satisfied?
> Like this:
> from("direct:database-save")
> .log("Fetch 500 records until no more ....")
> .aggregate(constant(true), batchAggregationStrategy())
> .completionPredicate().simple("${body.get('offset')} != -1")
> .completionTimeout(BATCH_TIME_OUT)
> .execute("direct:fetchBatchFromAPI") <====== LIKE THIS
> .log("All records are fetched ....");
>
> I bascially want to avoid looping when the aggregator has a predicate. I
> just want to ask if there is a method that I don't know about.
> Thank you,
> Michael Joyner
>