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.