I'm trying to generate a aggregate view of consecutive market data, which means we need to calculate the sum value every 2 message. say the data coming in as:
(V0,T0),(V1,T1),(V2,T2),(V3,T3)....
V
means value T
means timestamp when we receive the data.
We need to generate the sum for every 2 points say:
(R1=Sum(V0,V1),T1),(R2=Sum(V1,V2),T2),(R3=Sum(V2,V3),T3),....
Any suggestion how can we do this by using aggregator2
or we need to write a processor for this?
You are right, aggregator2 component is the good way to go. I would try something like that:
NB: It would be easier to parse if you could have a format like that:
V0,T0;V1,T1...
For more information: here is an article wrote by Claus Ibsen on parsing large file with Camel
After reading the source code of Aggregator, it turns out that camel only aggregate one message to one group, we have to build a "aggregator" for this purpose. here is the code: