camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-9177) combination of JPA-Component, loop and wiretap throws entitymanger cloesd exception
Date Tue, 29 Sep 2015 06:12:04 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-9177?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Claus Ibsen updated CAMEL-9177:
-------------------------------
    Fix Version/s: 2.16.0

> combination of JPA-Component, loop and wiretap throws entitymanger cloesd exception
> -----------------------------------------------------------------------------------
>
>                 Key: CAMEL-9177
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9177
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core, camel-jpa
>    Affects Versions: 2.15.2, 2.15.3
>         Environment: Camel 2.15.2 with Spring-Boot 1.2.3.RELEASE (with camel xml dsl)
>            Reporter: Pascal S.
>            Priority: Minor
>             Fix For: 2.16.0
>
>
> 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:
> {code}
> <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>
> {code}
> I think a possible fix can be to check that the entitymanager is null or closed. If null
or closed, create a new entitymanager.
> {code}
> public final class JpaHelper {
>     ...
>     public static EntityManager getTargetEntityManager(Exchange exchange, ...
>         ...
>         if (em == null || !em.isOpen()) {
>             // create a new entity manager
>             em = entityManagerFactory.createEntityManager();
>         ...
>         }
>     }
>     ...
> }
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message