Discussion:
[jboss-user] [jBPM] - Re: DroolsSpringJpaManager breaks when Database Server is restarted, how to handle it?
Maciej Swiderski
2013-08-13 05:19:29 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: DroolsSpringJpaManager breaks when Database Server is restarted, how to handle it?"

To view the discussion, visit: https://community.jboss.org/message/832426#832426

--------------------------------------------------------------
I believe that the issue is not really entity manager that is cached but the underlying db connection instance. The entity manager should be properly closed cleaned but when it tries to use connection it is broken and thus failing in general. I noticed that you use Apache DBCP connection pool so you can configure the pool to verify the connection on various phases - it will execute simple query to check if connection is valid before it is delivered to the application - in this case entity manager. See http://commons.apache.org/proper/commons-dbcp/configuration.html here for more details about validation of connection in DBCP.

HTH
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832426#832426]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2013-08-13 07:21:22 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: DroolsSpringJpaManager breaks when Database Server is restarted, how to handle it?"

To view the discussion, visit: https://community.jboss.org/message/832436#832436

--------------------------------------------------------------
Hi Maciejs,

I debug the application, and it turns out when I do something like start process(ksession.startProcess(..) ), inside DroolsSpringJpaManager these two functions will be invoked:
1. getApplicationScopedPersistenceContext
https://github.com/droolsjbpm/droolsjbpm-integration/blob/5.5.x/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java#L64-L92 https://github.com/droolsjbpm/droolsjbpm-integration/blob/5.5.x/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java#L64-L92

this one will never create new Entity Manager (except for the very first time execution). Which is not safe for Database Restart situation.

2. beginCommandScopedEntityManager
https://github.com/droolsjbpm/droolsjbpm-integration/blob/5.5.x/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java#L98-L119 https://github.com/droolsjbpm/droolsjbpm-integration/blob/5.5.x/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java#L98-L119

while this function will always find that entityManager is closed and then create new Entity Manager which is safe on Database Restart situation.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832436#832436]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...