Hi Claus,

I am no specialist, but in your case, it would seem the enrichment will
happen only on the first line of the csv, isn't it ?
>From what I understood, Jean-François, would want to enrich each line, with
the same data incoming from his database.
What if he synchronizes two routes ? A first one that read the CSV, and a
second one (triggered by the first) that selects in his database?

Regards,
2013/3/7 Claus Ibsen <claus.ib...@gmail.com>

>  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