JPA Component
The jpa component enables you to store and retrieve Java objects from persistent storage using EJB 3's Java Persistence Architecture (JPA), which is a standard interface layer that wraps Object/Relational Mapping (ORM) products such as OpenJPA, Hibernate, TopLink, and so on.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency>
<groupId> org.apache.camel</groupId>
<artifactId> camel-jpa</artifactId>
<version> x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
Sending to the endpoint
You can store a Java entity bean in a database by sending it to a JPA producer endpoint. The body of the In message is assumed to be an entity bean (that is, a POJO with an @Entity annotation on it) or a collection or array of entity beans.
If the body does not contain one of the previous listed types, put a Message Translator in front of the endpoint to perform the necessary conversion first.
Consuming from the endpoint
Consuming messages from a JPA consumer endpoint removes (or updates) entity beans in the database. This allows you to use a database table as a logical queue: consumers take messages from the queue and then delete/update them to logically remove them from the queue.
If you do not wish to delete the entity bean when it has been processed, you can specify consumeDelete=false on the URI. This will result in the entity being processed each poll.
If you would rather perform some update on the entity to mark it as processed (such as to exclude it from a future query) then you can annotate a method with @Consumed which will be invoked on your entity bean when the entity bean is consumed.
URI format
jpa:[ent