You need to add a special file in the JAR to have the converts auto
register in Camel when it boot up.

See section _Writing your own .._
http://camel.apache.org/type-converter.html

Also the Camel in Action book covers transformation and type
converters in chapter 3.
The book may help clear up a thing or two for you.

If you want to start simple then you may want to use mock endpoints
instead of JPA/JDBC to focus on the routing and transformation.
Then you can always later start to battle with the database.



On Fri, Sep 24, 2010 at 5:43 PM, shaun.bar...@rulefinancial.com
<shaun.bar...@rulefinancial.com> wrote:
>
> Hi,
> I started with the ETL example (http://camel.apache.org/etl-example.html) as
> I am looking at this library to do some message routing and transformation
> for a test facility in work. I simply wanted to see how to write and use a
> Custom Transformer - but it seems that this is not as straightforwards as I
> hoped. So (after writing my own project and having to accept failure) I
> altered EtlRoutes.java to this:
> public class EtlRoutes extends SpringRouteBuilder {
>    public void configure() throws Exception {
>
> //        from("file:src/data?noop=true")
> //            .convertBodyTo(PersonDocument.class)
> //            .to("jpa:org.apache.camel.example.etl.CustomerEntity");
> //
> //        // the following will dump the database to files
> //
> from("jpa:org.apache.camel.example.etl.CustomerEntity?consumeDelete=false&delay=3000&consumeLockEntity=false")
> //            .setHeader(Exchange.FILE_NAME, el("${in.body.userName}.xml"))
> //            .to("file:target/customers");
>
> //      from("file:src/data?noop=true")
> //      .convertBodyTo(PersonDocument.class)
> //      .to("file:target/customers");
>
>        from("file:src/data?noop=true")
>        .convertBodyTo(PersonDocument.class)
>        .to("class:org.apache.camel.example.etl.TryIt");
>
> //        from("file:target/customers?noop=true")
> //        .convertBodyTo(CustomerEntity.class)
> //        .to("class:org.apache.camel.example.etl.TryIt");
>
> //        from("class:org.apache.camel.example.etl.TryIt")
> //        .setHeader(Exchange.FILE_NAME, el("${in.body.fullDetails}.txt"))
> //        .to("file:target/tried");
>
>    }
> }
>
> and added a @Converter to the existing CustomerTransformer transformer like
> so:
>
>
> �...@converter
>    public TryIt toTryIt( PersonDocument customer, Exchange exchange )
> throws Exception {
>        TryIt it = new TryIt();
>        it.setDetails( customer.getFirstName(), customer.getLastName(),
> customer.getCity(), "02" );
>        return it;
>    }
>
>
> Yet no matter what I do the converter method is not used and instead the
> TryIt constructor arg is called with a value of GenericFile (i.e the raw
> file contents) the PersonDocument object hasn't been converted to and I am
> none the wiser why? This is most confusing since all I wanted to do is
> proove how to read, transform and write some simple data (in real life it
> will be more jms/xm/transform/xml ..)
>
> Any help/tips etc would be really appreciated?
>
> Thanks
> Shaun
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Newbie-Pls-help-ETL-Example-Modification-Doesn-t-work-tp2852839p2852839.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to