...
Configuring TransactionManager
Its strongly advised to configure the TransactionManager
instance used by the JPA component. If failed to do so each Since Camel 2.3 the JpaComponent
will auto lookup the TransactionManager
from the Registry. If Camel won't find any TransactionManager
instance registered, it will also look up for the TransactionTemplate
and try to extract TransactionManager
from it.
If none TransactionTemplate
is available in the registry, JpaEndpoint
will auto create their own instance of TransactionManager
which most often is not what you want.
For example, you can instantiate If more than single instance of the TransactionManager
is found, Camel will log a WARN. In such cases you might want to instantiate and explicitly configure a JPA component that references the myTransactionManager
transaction manager, as follows:
Code Block |
|
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
<property name="entityManagerFactory" ref="myEMFactory"/>
<property name="transactionManager" ref="myTransactionManager"/>
</bean>
|
In Camel 2.3 the JpaComponent
will auto lookup the TransactionManager
from the Registry which means you do not need to configure this on the JpaComponent
as shown above. You only need to do so if there is ambiguity, in which case Camel will log a WARN.
Using a consumer with a named query
...