Hi all,
We've been for long time now developing a complex event processing system that ( simplified version ahead !! ) involves a set of rules that in turn activates a set processes that fulfill human tasks and other kind of tasks.. This all is running in a StatefulKnowledgeSession with JPA persistence configured both for Drools and JBPM. We are running an stack of Drools, JBPM, Drools Integration, Drools fussion, etc..
We've been able to persist Drools sessions & JBPM processes in the same Persistence Context ( not without pain :( ) using different JTA implementations including ( but not limited to ) Bitronix & Atomikos.
What we are observing here is what seems to be some kind of race
condition between Drools and JBPM when running the knowledge session when JPA&JTA persistence is configured. Very often, as soon as after 2-3
processes get created as rule's consequences are fired in response of events inside the session we see how JBPM finds its instance nullified by Drools when
it tries to end a process and persist it.
We've been able to find where Drools decides to delete an instance of the process ... at a given time Drools executes JPAProcessInstanceManager.clearProcessInstances() [1] when it finalizes a SingleSessionCommand wich in turn calls disconnect() for *all* the local-stored processinstances ( wich gets populated with instances of processes every time a process is started in the knowledge session ):
public void clearProcessInstances() {for (ProcessInstance processInstance: new ArrayList<ProcessInstance>(processInstances.values())) {((ProcessInstanceImpl) processInstance).disconnect();}}