camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihullu <idehu...@online.nl>
Subject splitter, enricher, aggregator
Date Sat, 04 May 2013 21:53:01 GMT
I would like to do the following:

1. read a csv file
2. split it per line
3. per line enrich it with data coming from a xml source
4. per line execute a REST call to store the line 

As I have a pure Java background an no Spring experience I used the Java
DSL. 

This is what I created so far: 

       from("direct:start")
           .to("log: IN ==>")
           .split(body().tokenize("\n")).streaming()
           .unmarshal().bindy(BindyType.Csv,
Product.class.getPackage().getName())
           .bean(Transform.class)
           .to("log: JAXB ==>")
           .setHeader("id", simple("${body.id}")).log("id =
${in.header.id}")
           .pollEnrich("file:resource?fileName=PRD-onetrail.prd",new
AggregationStrategy())
           //.to("log: END ==>")
           //.to("mock:result")
           ;

The input is: 

      String inMsg = "0196-SJCLPAD2SGG\t112\n" + 
    		         "0434-SJDJFHRDFID\t3\n";



I am stuck at the Enrich part. It has the xml file as an input and uses the
Aggregation class to do the enrichment. The problem is that it consumes the
entire xml file. In the AggregationStrategy class I can browse through the
file and select the correct element by matching on the id field. This does
not sound very nice to me because the xml file is rather big. I do not want
to have the entire file in memory. 

I was actually looking for something like this. I want to do a
lookup/selection based on the body.id field in the XML file
(PRD-ontrail.prd) prior to the the polEnrich and enrich it with some
additional fields. 

So

Read File -> Split per line -> create Product Bean -> Add header
-------------------- 
                                                                            
|                                    |-> enrich
                                                                            
V                                   |
                                                                      
Select element from XML-------- 
                                                                        
using header/id

I hope this is clear what I want. 

Can somebody help me figure this out?

Regards
Izaak 




--
View this message in context: http://camel.465427.n5.nabble.com/splitter-enricher-aggregator-tp5732020.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message