You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by majid <mo...@peerius.com> on 2015/03/06 17:50:02 UTC

On Route Completion when using the aggregator

Hi All,

I have 2 camel routes
1st one is streaming and parsing an XML file, then aggregate a chunk of 1000
items and send it a seda queue.
2nd route is persisting these items to the database using jdbc batch.
I want on the completion of my second route, to run a finalize process only
once at the end.

The OnCompletion of the 2nd route seems to be called after each aggregation
and not only after the last aggregation.

Also, I tried to use an expression ${property.CamelSplitComplete} to check
when the last split happen to start it after some delay, but these property
does not seems to be propagated across exchanges of the 2 routes.

Anyone knows how can I fix this issue ?

Regards,





 




--
View this message in context: http://camel.465427.n5.nabble.com/On-Route-Completion-when-using-the-aggregator-tp5763746.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: On Route Completion when using the aggregator

Posted by majid <mo...@peerius.com>.
Hi Harald,

Yes, it is working :)
Thanks for the trick



--
View this message in context: http://camel.465427.n5.nabble.com/On-Route-Completion-when-using-the-aggregator-tp5763746p5763869.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: On Route Completion when using the aggregator

Posted by harald <su...@rainyday.de>.
I guess you have implemented your own AggregationStrategy so why don’t you check for the property on the new exchange and copy it to the old one which is forwarded?

Re: On Route Completion when using the aggregator

Posted by Harald Neiss <ne...@neissware.de>.
I guess you have implemented your own AggregationStrategy so why don’t you check for the property on the new exchange and copy it to the old one which is forwarded?

Re: On Route Completion when using the aggregator

Posted by majid <mo...@peerius.com>.
Thanks Harald

I was thinking to do exactly the same thing, send a signal to the seda queue
of the second route.
The only problem I have with this approach is that once I get the signal, I
need to wait until the last aggregated items to complete processing in this
route, which mean I have to put some delay before starting the last process,
and this is not accurate (because sometime the delay me be too short or too
long)





--
View this message in context: http://camel.465427.n5.nabble.com/On-Route-Completion-when-using-the-aggregator-tp5763746p5763761.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: On Route Completion when using the aggregator

Posted by harald <su...@rainyday.de>.
You are right, it’s in the properties not the header - sorry for that one.

If the implementation of the AggregationStrategy keeps the properties from the first exchange to be aggregated with the next 999 ones, the aggregated message will not contain the CamelSplitComplete because it is part of the last.

Easiest solution I see is to send a message at the end of route 1 to the seda queue indicating the end. Depends on what the second route has to do with it.

If this does not fit your needs, any details about the routes?


Re: On Route Completion when using the aggregator

Posted by majid <mo...@peerius.com>.
CamelSplitComplete  is in the property of the exchange, not in the header.
Yes, I enabled the tracing and also I run my app in debug mode to check the
properties and headers of the exchanges of my second route, and
CamelSplitComplete is always false.



--
View this message in context: http://camel.465427.n5.nabble.com/On-Route-Completion-when-using-the-aggregator-tp5763746p5763757.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: On Route Completion when using the aggregator

Posted by harald <su...@rainyday.de>.
Hi,

seda queues are decoupling your components. So your 2nd routes does not know the splitter in your first route. The consequence is that after each exchange on route 2 the OnCompletion is called. But it does not remove header information so the CamelSplitComplete should be part of the last exchange. Have you enabled tracing for route 2 and checked it?

regards,
harald


On 06 Mar 2015, at 17:50, majid <mo...@peerius.com> wrote:

> Hi All,
> 
> I have 2 camel routes
> 1st one is streaming and parsing an XML file, then aggregate a chunk of 1000
> items and send it a seda queue.
> 2nd route is persisting these items to the database using jdbc batch.
> I want on the completion of my second route, to run a finalize process only
> once at the end.
> 
> The OnCompletion of the 2nd route seems to be called after each aggregation
> and not only after the last aggregation.
> 
> Also, I tried to use an expression ${property.CamelSplitComplete} to check
> when the last split happen to start it after some delay, but these property
> does not seems to be propagated across exchanges of the 2 routes.
> 
> Anyone knows how can I fix this issue ?
> 
> Regards,
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/On-Route-Completion-when-using-the-aggregator-tp5763746.html
> Sent from the Camel - Users mailing list archive at Nabble.com.