Versions Compared

Key

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

...

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.

...

So lets start with the route definition in EtlRoutes

Wiki Markup
{snippet:id=example|lang=java|url=activemq/camel/trunk/examples/camel-example-etl/src/main/java/org/apache/camel/example/etl/EtlRoutes.java}

...

We're converting the body of the message to a PersonDocument which since this POJO as an @XmlRootElement annotation from JAXB will kick in the Type Converter to use JAXB to unmarshall the object.

Then we send the message with a PersonDocument body to the JPA endpoint. Notice how this endpoint specifies the expected type. So the Type Converter is gonna try convert the PersonDocument to a CustomerEntity. Here Camel will find the CustomerTransformer class which has an @Converter method

Wiki Markup
{snippet:id=example|lang=java|url=activemq/camel/trunk/examples/camel-example-etl/src/main/java/org/apache/camel/example/etl/CustomerTransformer.java}

...