On Thu, Mar 7, 2013 at 9:25 AM, Jean Francois LE BESCONT
<jflebesc...@gmail.com> wrote:
> Sorry if my explanation are not good ... :)
>
> I have a csv file. I would like  to process this file to enrich with data
> in sql table (then write enriched line in output).
>
> I  process file with a binding in business class :
>
> .from("file://mycsv.csv")
> .split()
> .tokenize("\n")
> .streaming()
> .unmarshal()
> .bindy(BindyType.Csv, AED.class)
>
> Then I would like to enrich the line converted in AED to add element from a
> DB table :
> .enrich("direct:datasource", new AggregationEnrichissementZone())
>
>
> The AggregationEnrichissementZone do my business transformation with both
> the current line and the content of the database which is in
> direct:datasource. It works no problem ! The
> direct:datasource is called correctly and retrieve the data from sql table.
> Initially I wrote it like this :
>
> from("direct:datasource")
> .setBody(constant("SELECT * FROM TEST"))
> .to("jdbc:dataSource")
> .to("direct:ds")
> .end();
>
> But direct:datasource is called for each line which cost to much time. I
> would like to make the database query only once for my csv file.
>

Ah okay then use the filter eip

 .from("file://mycsv.csv")
 .split()
   .tokenize("\n").streaming()
   .unmarshal().bindy(BindyType.Csv, AED.class)
   .filter(simple("${property.CamelSplitIndex} == 0"))
      ..enrich("direct:datasource", new AggregationEnrichissementZone())
    .end() // end filter
 .end() // end split


> Thanks
>
> JF
>


-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to