You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Daniel Seidewitz (JIRA)" <ji...@apache.org> on 2014/07/24 15:06:38 UTC

[jira] [Comment Edited] (CAMEL-7598) Camel does not clear the jpa session after each processed message batch

    [ https://issues.apache.org/jira/browse/CAMEL-7598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14073170#comment-14073170 ] 

Daniel Seidewitz edited comment on CAMEL-7598 at 7/24/14 1:05 PM:
------------------------------------------------------------------

Yes, i think the correct patch would be to call clear after the flush. 

I've implemented this fix and we now don't see any rise in used heap on our production system (system is running since 2 days and was showing heap rises of 100 MB / day before). 

Do you think it's possible to include the patch in release 2.12.5?

{code}
Index: components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java             (revision 89bf25387d3798620dc6972067e4a563e11f0b5a)
+++ components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java             (revision )
@@ -135,6 +135,7 @@
                 // commit
                 LOG.debug("Flushing EntityManager");
                 entityManager.flush();
+                entityManager.clear();
                 return messagePolled;
             }
         });
{code}


was (Author: dseidewitz):
Yes, i think the correct patch would be to call clear after the flush. 

I've implemented this fix and we now don't see any rise in used heap on our production system (system is running since 2 days and was showing heap rises of 100 MB / day before). 

{code}
Index: components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java             (revision 89bf25387d3798620dc6972067e4a563e11f0b5a)
+++ components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java             (revision )
@@ -135,6 +135,7 @@
                 // commit
                 LOG.debug("Flushing EntityManager");
                 entityManager.flush();
+                entityManager.clear();
                 return messagePolled;
             }
         });
{code}

> Camel does not clear the jpa session after each processed message batch
> -----------------------------------------------------------------------
>
>                 Key: CAMEL-7598
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7598
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jpa
>    Affects Versions: 2.12.3
>            Reporter: Daniel Seidewitz
>             Fix For: 2.13.3, 2.14.0
>
>
> We are using apache camel to poll from a database. As we want processed rows only to be updated we have disabled consumeDelete on the JPA endpoint. 
> During testing we found a large memory leak: all polled entities are kept in the session cache (we are using hibernate as persistence provider). 
> The issue seems to be in the JpaConsumer. In method poll() it calls enitityManager.joinTransaction() at the beginning and entitiyManager.flush() at the end of the method but it never calls  entityManager.clear(). As camel is reusing the underlying session during each poll() this causes the first level entity cache to grow indefinitely. 



--
This message was sent by Atlassian JIRA
(v6.2#6252)