camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Valsecchi <>
Subject JPA consumer reconnection
Date Mon, 04 Jan 2016 11:23:06 GMT

I'm using camel version 2.16.1 with openjdk 1.7, hibernate 5.0.3 and
postgres JDBC 9.4-1205.

I have a JPA consumer configured like that:
<route id="queue">
uri=";consumer.delay=1000&amp;maxMessagesPerPoll=1&amp;consumer.query=from order by id"/>

JPA is configured like that:
<bean id="entityManagerFactory"
    <property name="persistenceUnitName" value="persistenceUnit"/>
<bean id="jpaTxManager"
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    <property name="transactionManager" ref="jpaTxManager"/>

And my persistence.xml looks like that:
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
        <property name="javax.persistence.jdbc.driver"
value="org.postgresql.Driver" />
        <property name="javax.persistence.jdbc.url"
value="jdbc:postgresql://db/ZZZZZ" />
        <property name="javax.persistence.jdbc.user" value="www-data" />
        <property name="javax.persistence.jdbc.password" value="XXXXXX" />
        <property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQL9Dialect" />
        <property name="hibernate.connection.autoReconnect" value="true" />
        <property name="hibernate.connection.autoReconnectForPools"
value="true" />

        <property name="hibernate.connection.provider_class"
value="org.hibernate.connection.C3P0ConnectionProvider" />
        <property name="hibernate.c3p0.max_size" value="10" />
        <property name="hibernate.c3p0.min_size" value="1" />
        <property name="hibernate.c3p0.acquire_increment" value="1" />
        <property name="hibernate.c3p0.idle_test_period" value="300" />
        <property name="hibernate.c3p0.max_statements" value="0" />
        <property name="hibernate.c3p0.timeout" value="100" />
        <property name="hibernate.c3p0.validate" value="true" />
        <property name="hibernate.c3p0.testConnectionOnCheckout"
value="true" />
        <property name="hibernate.c3p0.breakAfterAcquireFailure"
value="false" />

In a nominal case, everything works fine.

If I bounce my database server Camel doesn't reconnect to the database and
I have logs like that:
11:17:49.756 [Camel (xxx) thread #0 - jpa://] DEBUG
o.h.e.t.internal.TransactionImpl - begin
11:17:49.761 [Camel (xxx) thread #0 - jpa://] DEBUG
org.hibernate.SQL - select as id1_0_, exploitati0_.query as
query2_0_, exploitati0_.uuid as uuid3_0_ from exploitation_queue
exploitati0_ order by
04-Jan-2016 11:17:49.761 WARNING [Camel (xxx) thread #0 -
com.mchange.v2.c3p0.impl.NewPooledConnection.handleThrowable [c3p0] A
PooledConnection that has already signalled a Connection error is still in
04-Jan-2016 11:17:49.762 WARNING [Camel (xxx) thread #0 -
com.mchange.v2.c3p0.impl.NewPooledConnection.handleThrowable [c3p0] Another
error has occurred [ org.postgresql.util.PSQLException: This connection has
been closed. ] which will not be reported to listeners!
 org.postgresql.util.PSQLException: This connection has been closed.

So looks like the connection pool is not re-connecting the DB because the
connection is still in use. I've looked all over the place at every level,
did a lot of tunning and found no solution to that.

Anybody have an idea on how to have JPA reconnect to the DB automatically?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message