I am using camel-jpa to poll messages from a database.  As recommended for
recovery on database failures, the persistence unit is configured with
Tomcat jdbc connection pool as the datasource and uses a test-on-borrow
strategy to validate connections.

The route still fails to recover if the database goes down.  I was able to
recreate the problem using an HSQL instance that I forced to go down during
route execution.  The stack trace shows that the PersistenceException is
thrown from JpaConsumer's doInTransaction().

As I was researching the problem I came across CAMEL-9608 which introduced
catching a PersistenceException and forcing the next poll to create a new
EntityManager.  It only performs this when the PersistenceException is
thrown from processBatch() 

So my question is, if PersistenceException can be thrown at
TransactionTemplate.execute() then is there any reason why the try/catch for
PersistenceException can't wrap this too?

>From reading this forum I know that the JPA component expects the
EntityManager to handle the connection recovery but I'm not on solid ground
yet in determining how the EntityManager is supposed to react under these
circumstances.  It seems like the locally stored EntityManager just doesn't
give up this bad connection.






--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-jpa-and-PersistenceException-tp5795205.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to