Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.15.2, 2.15.3
-
None
-
Camel 2.15.2 with Spring-Boot 1.2.3.RELEASE (with camel xml dsl)
-
Unknown
Description
Hi,
I have found a problem regarding a wiretap and the camel-jpa component. I have a route with an async split through a wiretap. In each route, I use a jpa producer to persist an entity. The problem is, that the entitymanager was closed before the async routes can reach the end. The cause is, that the same entitymanager is used in the async routes. The main route reaches the end and closes the entitymanager.
E.g. like the following route:
<route id="mainRoute> <from uri="direct:restendpoint"/> ... <to uri="jpa:MyEntity"/> ... <loop copy="true"> ... <wireTap uri="direct:asyncroute"/> </loop> </route> <route id="asyncRoute"> <from uri="direct:asyncroute"/> ... <to uri="jpa:MyEntity"/> ... </route>
I think a possible fix can be to check that the entitymanager is null or closed. If null or closed, create a new entitymanager.
public final class JpaHelper { ... public static EntityManager getTargetEntityManager(Exchange exchange, ... ... if (em == null || !em.isOpen()) { // create a new entity manager em = entityManagerFactory.createEntityManager(); ... } } ... }
Another solution can be in the wiretap. There where the exchange is copied, the "CamelEntityManager" property could be removed.
Currently, my quickfix is: At the beginning of the async route I remove the entitymanager from the exchange.
Attachments
Issue Links
- is depended upon by
-
CAMEL-8388 camel-jpa - Do not store CamelEntityManager as a header
- Resolved