You can also just configure fileExist=Append so you append to the
file, then you do not need the aggregator. However the aggregator
should be used if you need to do more complicated merging. But if you
just need to append, then the file component can do that out of the
box.
On Fri, Nov 21, 2014 at 2:04 PM, daninovac <danyno...@gmail.com> wrote:
> No, I want to write from a file (in.txt) to another file(out.txt)
> out.txt will contain the values after the split, but I get in out.txt just
> the last value from in.txt.
> I've read about it and I see that Camel write just the last value after the
> splitter and that I need to implement an aggregator.
>
> I think I need to save the id's from in.txt in a List then pass that list to
> out.txt just to write the values from my array.
>
> I'm proceeding like this.
>
> public class MyAggregationStrategy implements AggregationStrategy {
>
> public MyAggregationStrategy() {
> super();
> }
>
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange)
> {
> Message newIn = newExchange.getIn();
> Object newBody = newIn.getBody();
> ArrayList list = null;
> if (oldExchange == null) {
> list = new ArrayList();
> list.add(newBody);
> newIn.setBody(list);
> return newExchange;
> } else {
> Message in = oldExchange.getIn();
> list = in.getBody(ArrayList.class);
> list.add(newBody);
> return oldExchange;
> }
>
> }
>
> }
>
>
> *AND*
>
> <camel:route>
> <camel:from uri="file:src/main/resources/idList/" />
> <camel:split strategyRef="aggregatorStrategy">
> <camel:method ref="splitterBean"
> method="splitBody">
> </camel:method>
> <camel:to
> uri="file:src/main/resources/idListOut/" />
> </camel:split>
>
> </camel:route>
>
> where aggregatorStrategy is a bean to the class i've shown you.
> But the problem is that in out.txt all I see is only the last value, nothing
> changes. Where am I wrong? Please, I need a quick reply.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-noob-question-about-how-to-make-a-precisely-number-of-GET-request-on-a-url-tp5759365p5759447.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/