You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2015/09/29 08:17:05 UTC

[jira] [Resolved] (CAMEL-9177) combination of JPA-Component, loop and wiretap throws entitymanger cloesd exception

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

Claus Ibsen resolved CAMEL-9177.
--------------------------------
       Resolution: Fixed
    Fix Version/s: 2.15.4

Thanks for reporting and the suggestion.

> 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.
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.16.0, 2.15.4
>
>
> 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)