Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This example lives in the examples/camel-example-etl directory and will poll for XML files in the child src/data directory. When the files are detected, they are converted, using the fallback JAXB Type Converter to a PersonDocument class. This POJO is then transformed using a custom Type Converter into a CustomerEntity bean using the CustomerTransformer class. Then this bean is stored in the database via the JPA component.

Try looking at the source code which breaks down The code for this example is as follows

Java Class

Purpose

CustomerEntity

The JPA entity bean (i.e. a POJO with @Entity)

PersonDocument

The JAXB2 POJO used to parse the XML

CustomerTransformer

The custom Type Converter used to convert a PersonDocument into a CustomerEntity

EtlRoutes

The Camel routing DSL to define the flow from the files to the converter to the JPA endpoint

The there is the spring configuration file in src/resources/META-INF/services/camel-context.xml which defines the JPA template and tells Camel to look in the org.apache.camel.example.etl package to find its routes.

Code walkthrough

So lets start with the route definition in EtlRoutes

Running the example

To run the example we use the Camel Maven Plugin. For example from the source or binary distribution the following should work

...