Modified: websites/production/camel/content/jmx.html
==============================================================================
--- websites/production/camel/content/jmx.html (original)
+++ websites/production/camel/content/jmx.html Fri Aug 25 10:20:13 2017
@@ -36,17 +36,6 @@
<![endif]-->
- <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
- <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
- <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
-
- <script type="text/javascript">
- SyntaxHighlighter.defaults['toolbar'] = false;
- SyntaxHighlighter.all();
- </script>
<title>
Apache Camel: JMX
@@ -94,41 +83,32 @@
<p>Component allows consumers to subscribe to an mbean's Notifications. The
component supports passing the Notification object directly through the
Exchange or serializing it to XML according to the schema provided within this
project. This is a consumer only component. Exceptions are thrown if you
attempt to create a producer for it.</p>
<p>Maven users will need to add the following dependency to their
<code>pom.xml</code> for this component:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<parameter ac:name="">xml</parameter><plain-text-body>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jmx</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-]]></script>
-</div></div>
+</plain-text-body>
<h4 id="JMX-URIFormat">URI Format</h4>
<p>The component can connect to the local platform mbean server with the
following URI:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<plain-text-body>
jmx://platform?options
-]]></script>
-</div></div>
+</plain-text-body>
<p>A remote mbean server url can be provided following the initial JMX scheme
like so:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<plain-text-body>
jmx:service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi?options
-]]></script>
-</div></div>
+</plain-text-body>
<p>You can append query options to the URI in the following format,
?options=value&option2=value&...</p>
<h4 id="JMX-URIOptions">URI Options</h4>
-<div class="confluenceTableSmall">
+<parameter ac:name="class">confluenceTableSmall</parameter><rich-text-body>
<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th
colspan="1" rowspan="1" class="confluenceTh"><p>Property </p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p> Required </p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p> Default </p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p> Description
</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> format
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> xml </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> Format for the message body. Either "xml"
or "raw". If xml, the notification is serialized to xml. If raw, then the raw
java object is set as the body.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> user </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan
="1" rowspan="1" class="confluenceTd"><p> Credentials for making a remote
connection. </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> password </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Credentials for making a remote connection.
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>
objectDomain </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> yes
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> The domain for the mbean
you're connecting to. </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> objectName </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confl
uenceTd"><p> The name key for the mbean you're connecting to. This value is
mutually exclusive with the object properties that get passed. (see below)
</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>notificationFilter </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Reference to a bean that implements the
<code>NotificationFilter</code>. The #ref syntax should be used to reference
the bean via the <a shape="rect" href="registry.html">Registry</a>.
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>handback
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> Value to handback to the listener when a
notification is received. This value will be put in the mess
age header with the key "jmx.handback" </p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>testConnectionOnStartup </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> true </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <strong>Camel 2.11</strong> If true, the consumer
will throw an exception when unable to establish the JMX connection upon
startup. If false, the consumer will attempt to establish the JMX connection
every 'x' seconds until the connection is made – where 'x' is the
configured <em>reconnectDelay</em>.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>reconnectOnConnectionFailure </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> false </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <strong>Camel 2.11</strong> If true, the consumer
will attempt
to reconnect to the JMX server when any connection failure occurs. The
consumer will attempt to re-establish the JMX connection every 'x' seconds
until the connection is made-- where 'x' is the configured
<em>reconnectDelay</em>. </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>reconnectDelay </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> 10 seconds </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <strong>Camel 2.11</strong> The number of seconds to
wait before retrying creation of the initial connection or before reconnecting
a lost connection. </p></td></tr></tbody></table></div>
-</div>
-
-
-
+</rich-text-body>
<h4 id="JMX-ObjectNameConstruction">ObjectName Construction</h4>
<p>The URI must always have the objectDomain property. In addition, the URI
must contain either objectName or one or more properties that start with
"key."</p>
@@ -136,29 +116,20 @@ jmx:service:jmx:rmi:///jndi/rmi://localh
<h4 id="JMX-DomainwithNameproperty">Domain with Name property</h4>
<p>When the objectName property is provided, the following constructor is used
to build the ObjectName? for the mbean:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<plain-text-body>
ObjectName(String domain, String key, String value)
-]]></script>
-</div></div>
+</plain-text-body>
<p>The key value in the above will be "name" and the value will be the value
of the objectName property.</p>
<h4 id="JMX-DomainwithHashtable">Domain with Hashtable</h4>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<plain-text-body>
ObjectName(String domain, Hashtable<String,String> table)
-]]></script>
-</div></div>
+</plain-text-body>
<p>The Hashtable is constructed by extracting properties that start with
"key." The properties will have the "key." prefixed stripped prior to building
the Hashtable. This allows the URI to contain a variable number of properties
to identify the mbean.</p>
<h4 id="JMX-Example">Example</h4>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-from("jmx:platform?objectDomain=jmxExample&key.name=simpleBean").
- to("log:jmxEvent");
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/MyRouteBuilder.java}</plain-text-body>
<p><a shape="rect" class="external-link"
href="http://camel.apache.org/jmx-component-example.html">Full example</a></p>
@@ -166,29 +137,25 @@ from("jmx:platform?objectDomain=jmx
<p><strong>Available as of Camel 2.8</strong><br clear="none">
One popular use case for JMX is creating a monitor bean to monitor an
attribute on a deployed bean. This requires writing a few lines of Java code to
create the JMX monitor and deploy it. As shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<parameter ac:name="">java</parameter><plain-text-body>
CounterMonitor monitor = new CounterMonitor();
-monitor.addObservedObject(makeObjectName("simpleBean"));
-monitor.setObservedAttribute("MonitorNumber");
+monitor.addObservedObject(makeObjectName("simpleBean"));
+monitor.setObservedAttribute("MonitorNumber");
monitor.setNotify(true);
monitor.setInitThreshold(1);
monitor.setGranularityPeriod(500);
-registerBean(monitor, makeObjectName("counter"));
+registerBean(monitor, makeObjectName("counter"));
monitor.start();
-]]></script>
-</div></div>
+</plain-text-body>
<p>The 2.8 version introduces a new type of consumer that automatically
creates and registers a monitor bean for the specified objectName and
attribute. Additional endpoint attributes allow the user to specify the
attribute to monitor, type of monitor to create, and any other required
properties. The code snippet above is condensed into a set of endpoint
properties. The consumer uses these properties to create the CounterMonitor,
register it, and then subscribe to its changes. All of the JMX monitor types
are supported.</p>
<h4 id="JMX-Example.1">Example</h4>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-
from("jmx:platform?objectDomain=myDomain&objectName=simpleBean&"
+
-
"monitorType=counter&observedAttribute=MonitorNumber&initThreshold=1&"
+
- "granularityPeriod=500").to("mock:sink");
-]]></script>
-</div></div>
+<parameter ac:name="">java</parameter><plain-text-body>
+ from("jmx:platform?objectDomain=myDomain&objectName=simpleBean&" +
+
"monitorType=counter&observedAttribute=MonitorNumber&initThreshold=1&"
+
+ "granularityPeriod=500").to("mock:sink");
+</plain-text-body>
<p>The example above will cause a new Monitor Bean to be created and depoyed
to the local mbean server that monitors the "MonitorNumber" attribute on the
"simpleBean." Additional types of monitor beans and options are detailed below.
The newly deployed monitor bean is automatically undeployed when the consumer
is stopped. </p>
@@ -199,8 +166,7 @@ monitor.start();
<p>The monitor style consumer is only supported for the local mbean server.
JMX does not currently support remote deployment of mbeans without either
having the classes already remotely deployed or an adapter library on both the
client and server to facilitate a proxy deployment.</p>
-<h3 id="JMX-SeeAlso">See Also</h3>
-<ul><li><a shape="rect" href="configuring-camel.html">Configuring
Camel</a></li><li><a shape="rect"
href="component.html">Component</a></li><li><a shape="rect"
href="endpoint.html">Endpoint</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li></ul>
+<parameter ac:name=""><a shape="rect" href="endpoint-see-also.html">Endpoint
See Also</a></parameter>
<ul class="alternate"><li><a shape="rect" href="camel-jmx.html">Camel
JMX</a></li></ul></div>
</td>
<td valign="top">
Modified: websites/production/camel/content/jpa.html
==============================================================================
--- websites/production/camel/content/jpa.html (original)
+++ websites/production/camel/content/jpa.html Fri Aug 25 10:20:13 2017
@@ -36,17 +36,6 @@
<![endif]-->
- <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
- <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
- <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
-
- <script type="text/javascript">
- SyntaxHighlighter.defaults['toolbar'] = false;
- SyntaxHighlighter.all();
- </script>
<title>
Apache Camel: JPA
@@ -86,109 +75,54 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="JPA-JPAComponent">JPA
Component</h2><p>The <strong>jpa</strong> 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.</p><p>Maven users will need to add the following dependency to their
<code>pom.xml</code> for this component:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+<div class="wiki-content maincontent"><h2 id="JPA-JPAComponent">JPA
Component</h2><p>The <strong>jpa</strong> 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.</p><p>Maven users will need to add the following dependency to their
<code>pom.xml</code> for this component:</p><parameter
ac:name="">xml</parameter><plain-text-body><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>
-]]></script>
-</div></div><p>Sending to the endpoint</p><p>You can store a Java entity bean
in a database by sending it to a JPA producer endpoint. The body of the
<em>In</em> message is assumed to be an entity bean (that is, a POJO with an <a
shape="rect" class="external-link"
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html"
rel="nofollow">@Entity</a> annotation on it) or a collection or array of entity
beans.</p><p>If the body is a List of entities, make sure to use
<strong>entityType=java.util.ArrayList</strong> as a configuration passed to
the producer endpoint.</p><p>If the body does not contain one of the previous
listed types, put a <a shape="rect" href="message-translator.html">Message
Translator</a> in front of the endpoint to perform the necessary conversion
first.</p><p>From <strong>Camel 2.19</strong> onwards you can use
<strong>query</strong>, <strong>namedQuery</strong> and
<strong>nativeQuery </strong>option for the producer as well to retri
eve a set of entities or execute bulk update/delete.</p><h3
id="JPA-Consumingfromtheendpoint">Consuming from the endpoint</h3><p>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.</p><p>If you do not wish to delete the entity bean when it
has been processed (and when routing is done), you can specify
<code>consumeDelete=false</code> on the URI. This will result in the entity
being processed each poll.</p><p>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 <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html">@Consumed</a>
which will be invoked on your entity bean when the e
ntity bean when it has been processed (and when routing is done).</p><p>From
<strong>Camel 2.13</strong> onwards you can use <a shape="rect"
class="external-link"
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/PreConsumed.html">@PreConsumed</a>
which will be invoked on your entity bean before it has been processed (before
routing).</p><p>If you are consuming a lot (100K+) of rows and experience
OutOfMemory problems you should set the maximumResults to sensible
value.</p><p><strong>Note:</strong> Since <strong>Camel 2.18</strong>, JPA now
includes a <code>JpaPollingConsumer</code> implementation that better supports
Content Enricher using <code>pollEnrich()</code> to do an on-demand poll that
returns either none, one or a list of entities as the
result.</p><p> </p><h3 id="JPA-URIformat">URI format</h3><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[jpa:entityClassName[?options]
-]]></script>
-</div></div><p>For sending to the endpoint, the <em>entityClassName</em> is
optional. If specified, it helps the <a shape="rect"
href="type-converter.html">Type Converter</a> to ensure the body is of the
correct type.</p><p>For consuming, the <em>entityClassName</em> is
mandatory.</p><p>You can append query options to the URI in the following
format, <code>?option=value&option=value&...</code></p><h3
id="JPA-Options">Options</h3><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>entityType</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><em>entityClassName</em></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Overrides the <em>entityClassName</em> from
the U
RI.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>persistenceUnit</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>camel</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The JPA persistence unit used by
default.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumeDelete</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> If
<code>true</code>, the entity is deleted after it is consumed; if
<code>false</code>, the entity is not deleted.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>consumeLockEntity</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer
only:</strong> Specifies whether or not to set an exclusive lock on e
ach entity bean while processing the results from
polling.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>flushOnSend</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA producer only:</strong> Flushes
the <a shape="rect" class="external-link"
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html"
rel="nofollow">EntityManager</a> after the entity bean has been
persisted.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maximumResults</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> Set the
maximum number of results to retrieve on the <a shape="rect"
class="external-link"
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html"
rel="nofollow">Query</a>. <st
rong>Camel 2.19:</strong><span> it's also used for the producer when it
executes a query.</span></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>transactionManager</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>This option is <a shape="rect"
href="registry.html">Registry</a> based which requires the <code>#</code>
notation so that the given <code>transactionManager</code> being specified can
be looked up properly, e.g.
<code>transactionManager=#myTransactionManager</code>. It specifies the
transaction manager to use. If none provided, Camel will use a
<code>JpaTransactionManager</code> by default. Can be used to set a JTA
transaction manager (for integration with an EJB
container).</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.delay</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>500</code></p></td
><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer
>only:</strong> Delay in milliseconds between each poll.</p></td></tr><tr><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>consumer.initialDelay</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer
>only:</strong> Milliseconds before polling starts.</p></td></tr><tr><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>consumer.useFixedDelay</code></p></td><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> Set
>to <code>true</code> to use fixed delay between polls, otherwise fixed rate
>is used. See <a shape="rect" class="external-link"
>href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html"
> rel="nofollow">ScheduledExecutorService</a>
in JDK for details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxMessagesPerPoll</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> An
integer value to define the maximum number of messages to gather per poll. By
default, no maximum is set. Can be used to avoid polling many thousands of
messages when starting up the server. Set a value of 0 or negative to
disable.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.query</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>JPA consumer only:</strong> To use a custom
query when consuming data.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.namedQuery</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> 
;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA
consumer only:</strong> To use a named query when consuming
data.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.nativeQuery</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> To use
a custom native query when consuming data. You may want to use the option
<code>consumer.resultClass</code> also when using native
queries.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.parameters</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA consumer
only:</strong> This option is <a shape="rect" href="registry.html">Registry</a>
based which requires the <code>#</code> notation. This key/value mapping is
used for building the quer
y parameters. It's is expected to be of the generic type
<code>java.util.Map<String, Object></code> where the keys are the named
parameters of a given JPA query and the values are their corresponding
effective values you want to select for.</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>consumer.resultClass</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.7: JPA consumer
only:</strong> Defines the type of the returned payload (we will call
<code>entityManager.createNativeQuery(nativeQuery, resultClass)</code> instead
of <code>entityManager.createNativeQuery(nativeQuery)</code>). Without this
option, we will return an object array. Only has an affect when using in
conjunction with native query when consuming data.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.transacted</code></p></td><td
colspan="1" rowspan="1" c
lass="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.7.5/2.8.3/2.9: JPA consumer
only:</strong> Whether to run the consumer in transacted mode, by which all
messages will either commit or rollback, when the entire batch has been
processed. The default behavior (false) is to commit all the previously
successfully processed messages, and only rollback the last failed
message.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.lockModeType</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>WRITE</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel
2.11.2/2.12:</strong> To configure the lock mode on the consumer. The possible
values is defined in the enum <code>javax.persistence.LockModeType</code>. The
default value is changed to <code>PESSIMISTIC_WRITE</code> since <strong>Camel
2.13</strong>.</p></td></tr><tr><td colspan="1" rowspan="1" c
lass="confluenceTd"><p><code>consumer.SkipLockedEntity</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.13:</strong> To
configure whether to use NOWAIT on lock and silently skip the
entity.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>usePersist</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.5: JPA producer
only:</strong> Indicates to use <code>entityManager.persist(entity)</code>
instead of <code>entityManager.merge(entity)</code>. Note:
<code>entityManager.persist(entity)</code> doesn't work for detached entities
(where the EntityManager has to execute an UPDATE instead of an INSERT
query)!</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>joinTransaction</code></p></td><td colspan="1"
rowspan="1" class
="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.12.3:</strong> camel-jpa will join
transaction by default from Camel 2.12 onwards. You can use this option to turn
this off, for example if you use LOCAL_RESOURCE and join transaction doesn't
work with your JPA provider. This option can also be set globally on the
<code>JpaComponent</code>, instead of having to set it on all
endpoints.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p
class="p1">usePassedInEntityManager</p></td><td colspan="1" rowspan="1"
class="confluenceTd">false</td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.12.4/2.13.1 JPA producer only:</strong> If
set to true, then Camel will use the EntityManager from the header<p
class="p1">JpaConstants.ENTITYMANAGER instead of the configured entity manager
on the component/endpoint. This allows end users to control which entity
manager will be in use.</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">sharedEntityManager</td><td
colspan="1" rowspan="1" class="confluenceTd">false</td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.16:</strong> whether
to use spring's SharedEntityManager for the consumer/producer. A good idea may
be to set joinTransaction=false if this option is true, as sharing the entity
manager and mixing transactions is not a good idea. </p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><span>query</span></td><td
colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1"
rowspan="1" class="confluenceTd"><span>To use a custom query. <strong>Camel
2.19:</strong> it can be used for producer as well.</span></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">namedQuery</td><td colspan="1"
rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><span>To use a named query. <strong>Camel 2.19:</strong>
it can be used fo
r producer as well.</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">nativeQuery</td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd">To use a custom native query. <span>You may want to use
the option </span><code>resultClass</code><span> also when using native
queries. <strong>Camel 2.19:</strong><span> it can be used for producer as
well.</span></span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">parameters</td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><span>This option is </span><a shape="rect"
href="registry.html">Registry</a><span> based which requires the
</span><code>#</code><span> notation. This key/value mapping is used for
building the query parameters. It is expected to be of the generic type
</span><code>java.util.Map<String, Object></code><span> where the keys
are the named parameters of a given JPA que
ry and the values are their corresponding effective values you want to select
for. <strong>Camel 2.19:</strong><span> it can be used for producer as well.
When it's used for producer, <a shape="rect" href="simple.html">Simple</a>
expression can be used as a parameter value. It allows you to retrieve
parameter values from the message body header and
etc.</span></span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">resultClass</td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><span>Defines the type of the returned payload (we will
call </span><code>entityManager.createNativeQuery(nativeQuery,
resultClass)</code><span> instead of
</span><code>entityManager.createNativeQuery(nativeQuery)</code><span>).
Without this option, we will return an object array. Only has an affect when
using in conjunction with native query. <strong>Camel 2.19:</strong><span> it
can be used for producer as well.</span></span></td></tr
><tr><td colspan="1" rowspan="1" class="confluenceTd">useExecuteUpdate</td><td
>colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1"
>rowspan="1" class="confluenceTd"><strong>Camel 2.19: JPA producer
>only:</strong><span> To configure whether to use executeUpdate() when
>producer executes a query. When you use INSERT, UPDATE or DELETE statement as
>a named query, you need to specify this option to
>'true'.</span></td></tr></tbody></table></div><h3
>id="JPA-MessageHeaders">Message Headers</h3><p>Camel adds the following
>message headers to the exchange:</p><div class="confluenceTableSmall"><div
>class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
>rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1"
>rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1"
>class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
>rowspan="1" class="confluenceTd"><p><code>CamelJpaTemplate</code></p></td><td
>colspan="1" rowsp
an="1" class="confluenceTd"><p><code>JpaTemplate</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Not supported anymore
since Camel 2.12:</strong> The <code>JpaTemplate</code> object that is used to
access the entity bean. You need this object in some situations, for instance
in a type converter or when you are doing some custom processing. See <a
shape="rect" class="external-link"
href="https://issues.apache.org/jira/browse/CAMEL-5932">CAMEL-5932</a> for the
reason why the support for this header has been dropped.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelEntityManager</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>EntityManager</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA
consumer / Camel 2.12.2: JPA producer:</strong> The JPA
<code>EntityManager</code> object being used by <code>JpaConsumer</code> or
<code>JpaProducer</code>.</p></td></tr></tbody
></table></div></div>
-
-
-<h3 id="JPA-ConfiguringEntityManagerFactory">Configuring
EntityManagerFactory</h3><p>Its strongly advised to configure the JPA component
to use a specific <code>EntityManagerFactory</code> instance. If failed to do
so each <code>JpaEndpoint</code> will auto create their own instance of
<code>EntityManagerFactory</code> which most often is not what you
want.</p><p>For example, you can instantiate a JPA component that references
the <code>myEMFactory</code> entity manager factory, as follows:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<bean id="jpa"
class="org.apache.camel.component.jpa.JpaComponent">
- <property name="entityManagerFactory"
ref="myEMFactory"/>
+</plain-text-body><p>Sending to the endpoint</p><p>You can store a Java entity
bean in a database by sending it to a JPA producer endpoint. The body of the
<em>In</em> message is assumed to be an entity bean (that is, a POJO with an <a
shape="rect" class="external-link"
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html"
rel="nofollow">@Entity</a> annotation on it) or a collection or array of entity
beans.</p><p>If the body is a List of entities, make sure to use
<strong>entityType=java.util.ArrayList</strong> as a configuration passed to
the producer endpoint.</p><p>If the body does not contain one of the previous
listed types, put a <a shape="rect" href="message-translator.html">Message
Translator</a> in front of the endpoint to perform the necessary conversion
first.</p><p>From <strong>Camel 2.19</strong> onwards you can use
<strong>query</strong>, <strong>namedQuery</strong> and
<strong>nativeQuery </strong>option for the producer as well to
retrieve a set of entities or execute bulk update/delete.</p><h3
id="JPA-Consumingfromtheendpoint">Consuming from the endpoint</h3><p>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.</p><p>If you do not wish to delete the entity bean when it
has been processed (and when routing is done), you can specify
<code>consumeDelete=false</code> on the URI. This will result in the entity
being processed each poll.</p><p>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 <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html">@Consumed</a>
which will be invoked on your entity bean when
the entity bean when it has been processed (and when routing is
done).</p><p>From <strong>Camel 2.13</strong> onwards you can use <a
shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/PreConsumed.html">@PreConsumed</a>
which will be invoked on your entity bean before it has been processed (before
routing).</p><p>If you are consuming a lot (100K+) of rows and experience
OutOfMemory problems you should set the maximumResults to sensible
value.</p><p><strong>Note:</strong> Since <strong>Camel 2.18</strong>, JPA now
includes a <code>JpaPollingConsumer</code> implementation that better supports
Content Enricher using <code>pollEnrich()</code> to do an on-demand poll that
returns either none, one or a list of entities as the
result.</p><p> </p><h3 id="JPA-URIformat">URI
format</h3><plain-text-body>jpa:entityClassName[?options]
+</plain-text-body><p>For sending to the endpoint, the <em>entityClassName</em>
is optional. If specified, it helps the <a shape="rect"
href="type-converter.html">Type Converter</a> to ensure the body is of the
correct type.</p><p>For consuming, the <em>entityClassName</em> is
mandatory.</p><p>You can append query options to the URI in the following
format, <code>?option=value&option=value&...</code></p><h3
id="JPA-Options">Options</h3><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>entityType</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><em>entityClassName</em></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Overrides the <em>entityClassName</em> from
the URI.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>persistenceUnit</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>camel</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The JPA persistence unit used by
default.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumeDelete</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> If
<code>true</code>, the entity is deleted after it is consumed; if
<code>false</code>, the entity is not deleted.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>consumeLockEntity</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer
only:</strong> Specifies whether or not to set an exclusive loc
k on each entity bean while processing the results from
polling.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>flushOnSend</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA producer only:</strong> Flushes
the <a shape="rect" class="external-link"
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html"
rel="nofollow">EntityManager</a> after the entity bean has been
persisted.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maximumResults</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> Set the
maximum number of results to retrieve on the <a shape="rect"
class="external-link"
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html"
rel="nofollow">Query</a
>. <strong>Camel 2.19:</strong><span> it's also used for the producer when it
>executes a query.</span></p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>transactionManager</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p>This option is <a
>shape="rect" href="registry.html">Registry</a> based which requires the
><code>#</code> notation so that the given <code>transactionManager</code>
>being specified can be looked up properly, e.g.
><code>transactionManager=#myTransactionManager</code>. It specifies the
>transaction manager to use. If none provided, Camel will use a
><code>JpaTransactionManager</code> by default. Can be used to set a JTA
>transaction manager (for integration with an EJB
>container).</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>consumer.delay</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><code>500</code></
p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA
consumer only:</strong> Delay in milliseconds between each
poll.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.initialDelay</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer
only:</strong> Milliseconds before polling starts.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.useFixedDelay</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer
only:</strong> Set to <code>true</code> to use fixed delay between polls,
otherwise fixed rate is used. See <a shape="rect" class="external-link"
href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html"
rel="nofollow">ScheduledExecutorServic
e</a> in JDK for details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxMessagesPerPoll</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> An
integer value to define the maximum number of messages to gather per poll. By
default, no maximum is set. Can be used to avoid polling many thousands of
messages when starting up the server. Set a value of 0 or negative to
disable.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.query</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>JPA consumer only:</strong> To use a custom
query when consuming data.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.namedQuery</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p
> </p></td><td colspan="1" rowspan="1"
>class="confluenceTd"><p><strong>JPA consumer only:</strong> To use a named
>query when consuming data.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>consumer.nativeQuery</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer
>only:</strong> To use a custom native query when consuming data. You may want
>to use the option <code>consumer.resultClass</code> also when using native
>queries.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>consumer.parameters</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA
>consumer only:</strong> This option is <a shape="rect"
>href="registry.html">Registry</a> based which requires the <code>#</code>
>notation. This key/value mapping is used for building th
e query parameters. It's is expected to be of the generic type
<code>java.util.Map<String, Object></code> where the keys are the named
parameters of a given JPA query and the values are their corresponding
effective values you want to select for.</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>consumer.resultClass</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.7: JPA consumer
only:</strong> Defines the type of the returned payload (we will call
<code>entityManager.createNativeQuery(nativeQuery, resultClass)</code> instead
of <code>entityManager.createNativeQuery(nativeQuery)</code>). Without this
option, we will return an object array. Only has an affect when using in
conjunction with native query when consuming data.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.transacted</code></p></td><td
colspan="1" rowspan
="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.7.5/2.8.3/2.9: JPA consumer
only:</strong> Whether to run the consumer in transacted mode, by which all
messages will either commit or rollback, when the entire batch has been
processed. The default behavior (false) is to commit all the previously
successfully processed messages, and only rollback the last failed
message.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.lockModeType</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>WRITE</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel
2.11.2/2.12:</strong> To configure the lock mode on the consumer. The possible
values is defined in the enum <code>javax.persistence.LockModeType</code>. The
default value is changed to <code>PESSIMISTIC_WRITE</code> since <strong>Camel
2.13</strong>.</p></td></tr><tr><td colspan="1" rowspan
="1"
class="confluenceTd"><p><code>consumer.SkipLockedEntity</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.13:</strong> To
configure whether to use NOWAIT on lock and silently skip the
entity.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>usePersist</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.5: JPA producer
only:</strong> Indicates to use <code>entityManager.persist(entity)</code>
instead of <code>entityManager.merge(entity)</code>. Note:
<code>entityManager.persist(entity)</code> doesn't work for detached entities
(where the EntityManager has to execute an UPDATE instead of an INSERT
query)!</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>joinTransaction</code></p></td><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.12.3:</strong> camel-jpa will join
transaction by default from Camel 2.12 onwards. You can use this option to turn
this off, for example if you use LOCAL_RESOURCE and join transaction doesn't
work with your JPA provider. This option can also be set globally on the
<code>JpaComponent</code>, instead of having to set it on all
endpoints.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p
class="p1">usePassedInEntityManager</p></td><td colspan="1" rowspan="1"
class="confluenceTd">false</td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.12.4/2.13.1 JPA producer only:</strong> If
set to true, then Camel will use the EntityManager from the header<p
class="p1">JpaConstants.ENTITYMANAGER instead of the configured entity manager
on the component/endpoint. This allows end users to control which entity
manager will be in use.</p></td></tr><t
r><td colspan="1" rowspan="1" class="confluenceTd">sharedEntityManager</td><td
colspan="1" rowspan="1" class="confluenceTd">false</td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.16:</strong> whether
to use spring's SharedEntityManager for the consumer/producer. A good idea may
be to set joinTransaction=false if this option is true, as sharing the entity
manager and mixing transactions is not a good idea. </p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><span>query</span></td><td
colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1"
rowspan="1" class="confluenceTd"><span>To use a custom query. <strong>Camel
2.19:</strong> it can be used for producer as well.</span></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">namedQuery</td><td colspan="1"
rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><span>To use a named query. <strong>Camel 2.19:</strong>
it can be u
sed for producer as well.</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">nativeQuery</td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd">To use a custom native query. <span>You may want to use
the option </span><code>resultClass</code><span> also when using native
queries. <strong>Camel 2.19:</strong><span> it can be used for producer as
well.</span></span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">parameters</td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><span>This option is </span><a shape="rect"
href="registry.html">Registry</a><span> based which requires the
</span><code>#</code><span> notation. This key/value mapping is used for
building the query parameters. It is expected to be of the generic type
</span><code>java.util.Map<String, Object></code><span> where the keys
are the named parameters of a given J
PA query and the values are their corresponding effective values you want to
select for. <strong>Camel 2.19:</strong><span> it can be used for producer as
well. When it's used for producer, <a shape="rect"
href="simple.html">Simple</a> expression can be used as a parameter value. It
allows you to retrieve parameter values from the message body header and
etc.</span></span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">resultClass</td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><span>Defines the type of the returned payload (we will
call </span><code>entityManager.createNativeQuery(nativeQuery,
resultClass)</code><span> instead of
</span><code>entityManager.createNativeQuery(nativeQuery)</code><span>).
Without this option, we will return an object array. Only has an affect when
using in conjunction with native query. <strong>Camel 2.19:</strong><span> it
can be used for producer as well.</span></span></t
d></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">useExecuteUpdate</td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.19: JPA producer only:</strong><span> To
configure whether to use executeUpdate() when producer executes a query. When
you use INSERT, UPDATE or DELETE statement as a named query, you need to
specify this option to 'true'.</span></td></tr></tbody></table></div><h3
id="JPA-MessageHeaders">Message Headers</h3><p>Camel adds the following message
headers to the exchange:</p><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>CamelJ
paTemplate</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>JpaTemplate</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Not supported anymore since Camel
2.12:</strong> The <code>JpaTemplate</code> object that is used to access the
entity bean. You need this object in some situations, for instance in a type
converter or when you are doing some custom processing. See <a shape="rect"
class="external-link"
href="https://issues.apache.org/jira/browse/CAMEL-5932">CAMEL-5932</a> for the
reason why the support for this header has been dropped.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelEntityManager</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>EntityManager</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA
consumer / Camel 2.12.2: JPA producer:</strong> The JPA
<code>EntityManager</code> object being used by <code>JpaConsumer</code> or
<code>JpaProducer</code>.</p></td></tr></tbody></table></div></rich-text-body><h3
id="JPA-ConfiguringEntityManagerFactory">Configuring
EntityManagerFactory</h3><p>Its strongly advised to configure the JPA component
to use a specific <code>EntityManagerFactory</code> instance. If failed to do
so each <code>JpaEndpoint</code> will auto create their own instance of
<code>EntityManagerFactory</code> which most often is not what you
want.</p><p>For example, you can instantiate a JPA component that references
the <code>myEMFactory</code> entity manager factory, as follows:</p><parameter
ac:name="">xml</parameter><plain-text-body><bean id="jpa"
class="org.apache.camel.component.jpa.JpaComponent">
+ <property name="entityManagerFactory" ref="myEMFactory"/>
</bean>
-]]></script>
-</div></div><p>In <strong>Camel 2.3</strong> the <code>JpaComponent</code>
will auto lookup the <code>EntityManagerFactory</code> from the <a shape="rect"
href="registry.html">Registry</a> which means you do not need to configure this
on the <code>JpaComponent</code> as shown above. You only need to do so if
there is ambiguity, in which case Camel will log a WARN.</p><h3
id="JPA-ConfiguringTransactionManager">Configuring
TransactionManager</h3><p>Since <strong>Camel 2.3</strong> the
<code>JpaComponent</code> will auto lookup the <code>TransactionManager</code>
from the <a shape="rect" href="registry.html">Registry.</a> If Camel won't find
any <code>TransactionManager</code> instance registered, it will also look up
for the <code>TransactionTemplate</code> and try to
extract <code>TransactionManager</code> from it.</p><p>If none
<code>TransactionTemplate</code> is available in the registry,
<code>JpaEndpoint</code> will auto create their own instance of
<code>TransactionMan
ager</code> which most often is not what you want.</p><p>If more than single
instance of the <code>TransactionManager</code> is found, Camel will log a
WARN. In such cases you might want to instantiate and explicitly configure a
JPA component that references the <code>myTransactionManager</code> transaction
manager, as follows:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<bean id="jpa"
class="org.apache.camel.component.jpa.JpaComponent">
- <property name="entityManagerFactory"
ref="myEMFactory"/>
- <property name="transactionManager"
ref="myTransactionManager"/>
+</plain-text-body><p>In <strong>Camel 2.3</strong> the
<code>JpaComponent</code> will auto lookup the
<code>EntityManagerFactory</code> from the <a shape="rect"
href="registry.html">Registry</a> which means you do not need to configure this
on the <code>JpaComponent</code> as shown above. You only need to do so if
there is ambiguity, in which case Camel will log a WARN.</p><h3
id="JPA-ConfiguringTransactionManager">Configuring
TransactionManager</h3><p>Since <strong>Camel 2.3</strong> the
<code>JpaComponent</code> will auto lookup the <code>TransactionManager</code>
from the <a shape="rect" href="registry.html">Registry.</a> If Camel won't find
any <code>TransactionManager</code> instance registered, it will also look up
for the <code>TransactionTemplate</code> and try to
extract <code>TransactionManager</code> from it.</p><p>If none
<code>TransactionTemplate</code> is available in the registry,
<code>JpaEndpoint</code> will auto create their own instance of <code>Transact
ionManager</code> which most often is not what you want.</p><p>If more than
single instance of the <code>TransactionManager</code> is found, Camel will log
a WARN. In such cases you might want to instantiate and explicitly configure a
JPA component that references the <code>myTransactionManager</code> transaction
manager, as follows:</p><parameter
ac:name="">xml</parameter><plain-text-body><bean id="jpa"
class="org.apache.camel.component.jpa.JpaComponent">
+ <property name="entityManagerFactory" ref="myEMFactory"/>
+ <property name="transactionManager" ref="myTransactionManager"/>
</bean>
-]]></script>
-</div></div><h3 id="JPA-Usingaconsumerwithanamedquery">Using a consumer with a
named query</h3><p>For consuming only selected entities, you can use the
<code>consumer.namedQuery</code> URI query option. First, you have to define
the named query in the JPA Entity class:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[@Entity
-@NamedQuery(name = "step1", query = "select x from MultiSteps x
where x.step = 1")
+</plain-text-body><h3 id="JPA-Usingaconsumerwithanamedquery">Using a consumer
with a named query</h3><p>For consuming only selected entities, you can use the
<code>consumer.namedQuery</code> URI query option. First, you have to define
the named query in the JPA Entity class:</p><plain-text-body>@Entity
+@NamedQuery(name = "step1", query = "select x from MultiSteps x where x.step =
1")
public class MultiSteps {
...
}
-]]></script>
-</div></div><p>After that you can define a consumer uri like this one:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[from("jpa://org.apache.camel.examples.MultiSteps?consumer.namedQuery=step1")
-.to("bean:myBusinessLogic");
-]]></script>
-</div></div><h3 id="JPA-Usingaconsumerwithaquery">Using a consumer with a
query</h3><p>For consuming only selected entities, you can use the
<code>consumer.query</code> URI query option. You only have to define the query
option:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[from("jpa://org.apache.camel.examples.MultiSteps?consumer.query=select
o from org.apache.camel.examples.MultiSteps o where o.step = 1")
-.to("bean:myBusinessLogic");
-]]></script>
-</div></div><h3 id="JPA-Usingaconsumerwithanativequery">Using a consumer with
a native query</h3><p>For consuming only selected entities, you can use the
<code>consumer.nativeQuery</code> URI query option. You only have to define the
native query option:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[from("jpa://org.apache.camel.examples.MultiSteps?consumer.nativeQuery=select
* from MultiSteps where step = 1")
-.to("bean:myBusinessLogic");
-]]></script>
-</div></div><p>If you use the native query option, you will receive an object
array in the message body.</p><p> </p><h3
id="JPA-Usingaproducerwithanamedquery">Using a producer with a named
query</h3><p>For retrieving selected entities or execute bulk update/delete,
you can use the <code>namedQuery</code> URI query option. First, you
have to define the named query in the JPA Entity class:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[@Entity
-@NamedQuery(name = "step1", query = "select x from MultiSteps x
where x.step = 1")
+</plain-text-body><p>After that you can define a consumer uri like this
one:</p><plain-text-body>from("jpa://org.apache.camel.examples.MultiSteps?consumer.namedQuery=step1")
+.to("bean:myBusinessLogic");
+</plain-text-body><h3 id="JPA-Usingaconsumerwithaquery">Using a consumer with
a query</h3><p>For consuming only selected entities, you can use the
<code>consumer.query</code> URI query option. You only have to define the query
option:</p><plain-text-body>from("jpa://org.apache.camel.examples.MultiSteps?consumer.query=select
o from org.apache.camel.examples.MultiSteps o where o.step = 1")
+.to("bean:myBusinessLogic");
+</plain-text-body><h3 id="JPA-Usingaconsumerwithanativequery">Using a consumer
with a native query</h3><p>For consuming only selected entities, you can use
the <code>consumer.nativeQuery</code> URI query option. You only have to define
the native query
option:</p><plain-text-body>from("jpa://org.apache.camel.examples.MultiSteps?consumer.nativeQuery=select
* from MultiSteps where step = 1")
+.to("bean:myBusinessLogic");
+</plain-text-body><p>If you use the native query option, you will receive an
object array in the message body.</p><p> </p><h3
id="JPA-Usingaproducerwithanamedquery">Using a producer with a named
query</h3><p>For retrieving selected entities or execute bulk update/delete,
you can use the <code>namedQuery</code> URI query option. First, you
have to define the named query in the JPA Entity
class:</p><plain-text-body>@Entity
+@NamedQuery(name = "step1", query = "select x from MultiSteps x where x.step =
1")
public class MultiSteps {
...
}
-]]></script>
-</div></div><p>After that you can define a producer uri like this one:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[from("direct:namedQuery")
-.to("jpa://org.apache.camel.examples.MultiSteps?namedQuery=step1");
-]]></script>
-</div></div><h3 id="JPA-Usingaproducerwithaquery">Using a producer with a
query</h3><p>For retrieving selected entities or execute bulk update/delete,
you can use the <code>query</code> URI query option. You only have to
define the query option:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[from("direct:query")
-.to("jpa://org.apache.camel.examples.MultiSteps?query=select o from
org.apache.camel.examples.MultiSteps o where o.step = 1");
-]]></script>
-</div></div><h3 id="JPA-Usingaproducerwithanativequery">Using a producer with
a native query</h3><p>For retrieving selected entities or execute bulk
update/delete, you can use the <code>nativeQuery</code> URI query
option. You only have to define the native query option:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[from("direct:nativeQuery")
-.to("jpa://org.apache.camel.examples.MultiSteps?resultClass=org.apache.camel.examples.MultiSteps&nativeQuery=select
* from MultiSteps where step = 1");
-]]></script>
-</div></div><p>If you use the native query option without specifying
<em>resultClass</em>, you will receive an object array in the message
body.</p><p> </p><h3 id="JPA-Example">Example</h3><p>See <a shape="rect"
href="tracer-example.html">Tracer Example</a> for an example using <a
shape="rect" href="jpa.html">JPA</a> to store traced messages into a
database.</p><h3 id="JPA-UsingtheJPAbasedidempotentrepository">Using the JPA
based idempotent repository</h3><p>In this section we will use the JPA based
idempotent repository.</p><p>First we need to setup a
<code>persistence-unit</code> in the persistence.xml file:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-<persistence-unit name="idempotentDb"
transaction-type="RESOURCE_LOCAL">
-
<class>org.apache.camel.processor.idempotent.jpa.MessageProcessed</class>
-
- <properties>
- <property name="openjpa.ConnectionURL"
value="jdbc:derby:target/idempotentTest;create=true"/>
- <property name="openjpa.ConnectionDriverName"
value="org.apache.derby.jdbc.EmbeddedDriver"/>
- <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema"/>
- <property name="openjpa.Log" value="DefaultLevel=WARN,
Tool=INFO"/>
- <property name="openjpa.Multithreaded"
value="true"/>
- </properties>
-</persistence-unit>
-]]></script>
-</div></div>Second we have to setup a
<code>org.springframework.orm.jpa.JpaTemplate</code> which is used by the
<code>org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository</code>:<div
class="error"><span class="error">Error formatting macro: snippet:
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span>
</div>Afterwards we can configure our
<code>org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository</code>:<div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-<!-- we define our jpa based idempotent repository we want to use in the
file consumer -->
-<bean id="jpaStore"
class="org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository">
- <!-- Here we refer to the entityManagerFactory -->
- <constructor-arg index="0"
ref="entityManagerFactory"/>
- <!-- This 2nd parameter is the name (= a category name).
- You can have different repositories with different names -->
- <constructor-arg index="1" value="FileConsumer"/>
-</bean>
-]]></script>
-</div></div>And finally we can create our JPA idempotent repository in the
spring XML file as well:<div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<camelContext
xmlns="http://camel.apache.org/schema/spring">
- <route id="JpaMessageIdRepositoryTest">
- <from uri="direct:start" />
- <idempotentConsumer messageIdRepositoryRef="jpaStore">
+</plain-text-body><p>After that you can define a producer uri like this
one:</p><plain-text-body>from("direct:namedQuery")
+.to("jpa://org.apache.camel.examples.MultiSteps?namedQuery=step1");
+</plain-text-body><h3 id="JPA-Usingaproducerwithaquery">Using a producer with
a query</h3><p>For retrieving selected entities or execute bulk update/delete,
you can use the <code>query</code> URI query option. You only have to
define the query option:</p><plain-text-body>from("direct:query")
+.to("jpa://org.apache.camel.examples.MultiSteps?query=select o from
org.apache.camel.examples.MultiSteps o where o.step = 1");
+</plain-text-body><h3 id="JPA-Usingaproducerwithanativequery">Using a producer
with a native query</h3><p>For retrieving selected entities or execute bulk
update/delete, you can use the <code>nativeQuery</code> URI query
option. You only have to define the native query
option:</p><plain-text-body>from("direct:nativeQuery")
+.to("jpa://org.apache.camel.examples.MultiSteps?resultClass=org.apache.camel.examples.MultiSteps&nativeQuery=select
* from MultiSteps where step = 1");
+</plain-text-body><p>If you use the native query option without specifying
<em>resultClass</em>, you will receive an object array in the message
body.</p><p> </p><h3 id="JPA-Example">Example</h3><p>See <a shape="rect"
href="tracer-example.html">Tracer Example</a> for an example using <a
shape="rect" href="jpa.html">JPA</a> to store traced messages into a
database.</p><h3 id="JPA-UsingtheJPAbasedidempotentrepository">Using the JPA
based idempotent repository</h3><p>In this section we will use the JPA based
idempotent repository.</p><p>First we need to setup a
<code>persistence-unit</code> in the persistence.xml
file:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-jpa/src/test/resources/META-INF/persistence.xml}</plain-text-body>Second
we have to setup a <code>org.springframework.orm.jpa.JpaTemplate</code> which
is used by the
<code>org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository</code>:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/
trunk/components/camel-jpa/src/test/resources/org/apache/camel/processor/jpa/spring.xml}</plain-text-body>Afterwards
we can configure our
<code>org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository</code>:<plain-text-body>{snippet:id=jpaStore|lang=xml|url=camel/trunk/components/camel-jpa/src/test/resources/org/apache/camel/processor/jpa/fileConsumerJpaIdempotentTest-config.xml}</plain-text-body>And
finally we can create our JPA idempotent repository in the spring XML file as
well:</p><parameter ac:name="">xml</parameter><plain-text-body><camelContext
xmlns="http://camel.apache.org/schema/spring">
+ <route id="JpaMessageIdRepositoryTest">
+ <from uri="direct:start" />
+ <idempotentConsumer messageIdRepositoryRef="jpaStore">
<header>messageId</header>
- <to uri="mock:result" />
+ <to uri="mock:result" />
</idempotentConsumer>
</route>
</camelContext>
-]]></script>
-</div></div><div class="confluence-information-macro
confluence-information-macro-information"><p class="title">When running this
Camel component tests inside your IDE</p><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>In case you run the <a
shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/src/test">tests
of this component</a> directly inside your IDE (and not necessarily through
Maven itself) then you could spot exceptions like:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[org.springframework.transaction.CannotCreateTransactionException:
Could not open JPA EntityManager for transaction; nested exception is
+</plain-text-body><parameter ac:name="title">When running this Camel component
tests inside your IDE</parameter><rich-text-body><p>In case you run the <a
shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/src/test">tests
of this component</a> directly inside your IDE (and not necessarily through
Maven itself) then you could spot exceptions like:</p><parameter
ac:name="">java</parameter><plain-text-body>org.springframework.transaction.CannotCreateTransactionException:
Could not open JPA EntityManager for transaction; nested exception is
<openjpa-2.2.1-r422266:1396819 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: This configuration disallows
runtime optimization,
-but the following listed types were not enhanced at build time or at class
load time with a javaagent: "org.apache.camel.examples.SendEmail".
+but the following listed types were not enhanced at build time or at class
load time with a javaagent: "org.apache.camel.examples.SendEmail".
at
org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:427)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
@@ -196,13 +130,9 @@ but the following listed types were not
at
org.apache.camel.processor.jpa.JpaRouteTest.createCamelContext(JpaRouteTest.java:67)
at
org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:238)
at
org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:208)
-]]></script>
-</div></div><p>The problem here is that the source has been
compiled/recompiled through your IDE and not through Maven itself which would
<a shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/pom.xml">enhance
the byte-code at build time</a>. To overcome this you would need to enable <a
shape="rect" class="external-link"
href="http://openjpa.apache.org/entity-enhancement.html#dynamic-enhancement">dynamic
byte-code enhancement of OpenJPA</a>. As an example assuming the current
OpenJPA version being used in Camel itself is 2.2.1, then as running the tests
inside your favorite IDE you would need to pass the following argument to the
JVM:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+</plain-text-body><p>The problem here is that the source has been
compiled/recompiled through your IDE and not through Maven itself which would
<a shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/pom.xml">enhance
the byte-code at build time</a>. To overcome this you would need to enable <a
shape="rect" class="external-link"
href="http://openjpa.apache.org/entity-enhancement.html#dynamic-enhancement">dynamic
byte-code enhancement of OpenJPA</a>. As an example assuming the current
OpenJPA version being used in Camel itself is 2.2.1, then as running the tests
inside your favorite IDE you would need to pass the following argument to the
JVM:</p><plain-text-body>
-javaagent:<path_to_your_local_m2_cache>/org/apache/openjpa/openjpa/2.2.1/openjpa-2.2.1.jar
-]]></script>
-</div></div><p>Then it will all become green again <img class="emoticon
emoticon-smile"
src="https://cwiki.apache.org/confluence/s/en_GB/5997/6f42626d00e36f53fe51440403446ca61552e2a2.1/_/images/icons/emoticons/smile.png"
data-emoticon-name="smile" alt="(smile)"></p></div></div><p></p><h3
id="JPA-SeeAlso">See Also</h3>
-<ul><li><a shape="rect" href="configuring-camel.html">Configuring
Camel</a></li><li><a shape="rect"
href="component.html">Component</a></li><li><a shape="rect"
href="endpoint.html">Endpoint</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li></ul><ul
class="alternate"><li><a shape="rect" href="tracer-example.html">Tracer
Example</a></li></ul></div>
+</plain-text-body><p>Then it will all become green again <img class="emoticon
emoticon-smile"
src="https://cwiki.apache.org/confluence/s/en_GB/5997/6f42626d00e36f53fe51440403446ca61552e2a2.1/_/images/icons/emoticons/smile.png"
data-emoticon-name="smile" alt="(smile)"></p></rich-text-body><p><parameter
ac:name=""><a shape="rect" href="endpoint-see-also.html">Endpoint See
Also</a></parameter></p><ul class="alternate"><li><a shape="rect"
href="tracer-example.html">Tracer Example</a></li></ul></div>
</td>
<td valign="top">
<div class="navigation">