You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Meissa Sakho <mb...@gmail.com> on 2018/02/20 16:40:32 UTC

Using the aggregator pattern

Hello everyone,

I'm trying to use the Aggregator Pattern with the 2 requirements below:

A large quantity of fixed loan data is sent to the application through the
file system.
The loans should be aggregated with a defined correlation id to batch of 20
files.
When a laps of 10 seconds elapses, the aggregated files should be completed
even if the number of files is not equals to 20.

Below is a snipped of the route.

public void configure() throws Exception {
   from("file:"+LOAN_FOLDER)
   .aggregate(header("company"), new LoansAggregationStrategy())
           * .completionSize(20)*
*            .completionTimeout(10000)*


.to("file://"+LOAN_OUTPUT_FOLDER+"?fileName=loan-${date:now:yyyy_MM_dd_hh_mm_ss_SS}.xml");

}

I'm using the competionSize condition to control the number of messages and
it works fine.
I'm trying to combine it with the completionTimeout so that aggregated
messages are built if a number of 10 second is reached even if there are
not 20 messages to be aggregated.

The problem is with the second condition. When the route runs, I can see
from the output that the second condition is not met.
Do you have an advice on how to achieve this second condition?

Thanks,
Meissa

Re: Using the aggregator pattern

Posted by Meissa Sakho <mb...@gmail.com>.
I have tried the completionInterval option instead. It seems to work better.

2018-02-21 7:19 GMT+01:00 Sorin Dan <da...@gmail.com>:

> Hello,
>
> Form my understanding the completionTimeout is the amount of time waited
> for a new piece of information to be available on the channel. So if it
> isn't detected anything on the channel for 10 seconds, the aggregation is
> considered completed and the message is sent to the file.
>
> Best regards,
> Sorin
>
> 2018-02-20 18:40 GMT+02:00 Meissa Sakho <mb...@gmail.com>:
>
> > Hello everyone,
> >
> > I'm trying to use the Aggregator Pattern with the 2 requirements below:
> >
> > A large quantity of fixed loan data is sent to the application through
> the
> > file system.
> > The loans should be aggregated with a defined correlation id to batch of
> 20
> > files.
> > When a laps of 10 seconds elapses, the aggregated files should be
> completed
> > even if the number of files is not equals to 20.
> >
> > Below is a snipped of the route.
> >
> > public void configure() throws Exception {
> >    from("file:"+LOAN_FOLDER)
> >    .aggregate(header("company"), new LoansAggregationStrategy())
> >            * .completionSize(20)*
> > *            .completionTimeout(10000)*
> >
> >
> > .to("file://"+LOAN_OUTPUT_FOLDER+"?fileName=loan-${date:
> > now:yyyy_MM_dd_hh_mm_ss_SS}.xml");
> >
> > }
> >
> > I'm using the competionSize condition to control the number of messages
> and
> > it works fine.
> > I'm trying to combine it with the completionTimeout so that aggregated
> > messages are built if a number of 10 second is reached even if there are
> > not 20 messages to be aggregated.
> >
> > The problem is with the second condition. When the route runs, I can see
> > from the output that the second condition is not met.
> > Do you have an advice on how to achieve this second condition?
> >
> > Thanks,
> > Meissa
> >
>

Re: Using the aggregator pattern

Posted by Sorin Dan <da...@gmail.com>.
Hello,

Form my understanding the completionTimeout is the amount of time waited
for a new piece of information to be available on the channel. So if it
isn't detected anything on the channel for 10 seconds, the aggregation is
considered completed and the message is sent to the file.

Best regards,
Sorin

2018-02-20 18:40 GMT+02:00 Meissa Sakho <mb...@gmail.com>:

> Hello everyone,
>
> I'm trying to use the Aggregator Pattern with the 2 requirements below:
>
> A large quantity of fixed loan data is sent to the application through the
> file system.
> The loans should be aggregated with a defined correlation id to batch of 20
> files.
> When a laps of 10 seconds elapses, the aggregated files should be completed
> even if the number of files is not equals to 20.
>
> Below is a snipped of the route.
>
> public void configure() throws Exception {
>    from("file:"+LOAN_FOLDER)
>    .aggregate(header("company"), new LoansAggregationStrategy())
>            * .completionSize(20)*
> *            .completionTimeout(10000)*
>
>
> .to("file://"+LOAN_OUTPUT_FOLDER+"?fileName=loan-${date:
> now:yyyy_MM_dd_hh_mm_ss_SS}.xml");
>
> }
>
> I'm using the competionSize condition to control the number of messages and
> it works fine.
> I'm trying to combine it with the completionTimeout so that aggregated
> messages are built if a number of 10 second is reached even if there are
> not 20 messages to be aggregated.
>
> The problem is with the second condition. When the route runs, I can see
> from the output that the second condition is not met.
> Do you have an advice on how to achieve this second condition?
>
> Thanks,
> Meissa
>