title: Apache Camel with JPA-Component, loop and wiretap throws entitymanger cloesd exception
body: <p>I have a problem regarding a wiretap and the jpa-camel 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.</p>
  
  <p>E.g. like the following route:</p>
  
  <pre><code>&lt;route id="mainRoute&gt;
      &lt;from uri="direct:restendpoint"/&gt;
      ...
      &lt;to uri="jpa:MyEntity"/&gt;
      ...
      &lt;loop copy="true"&gt;
          ...
          &lt;wireTap uri="direct:asyncroute"/&gt;
      &lt;/loop&gt;
  &lt;/route&gt;
  
  &lt;route id="asyncRoute"&gt;
      &lt;from uri="direct:asyncroute"/&gt;
      ...
      &lt;to uri="jpa:MyEntity"/&gt;
      ...
  &lt;/route&gt;
  </code></pre>
  
  <p>I think a possible fix can be to check that the entitymanager is null or closed. If null or closed, create a new entitymanager.</p>
  
  <pre><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></pre>
  
  <p>Another solution can be in the wiretap. There where the exchange is copied, the "CamelEntityManager" property could be removed.</p>
  
  <p>My quickfix: At the beginning of the async route I remove the entitymanager from the exchange.</p>
  
  <p>I use Camel 2.15.2 with Spring-Boot 1.2.3.RELEASE</p>
  
  <p>Does someone knows a better solution?</p>