Thanks Mauricio for your kind response, and kick, as usual ;-)<br><br> Sure, we see lots of rolled back transactions ... Everywhere!<br><br> Let me see if I'm getting this right, What you mean is that there is no way for the JPA persistence of Drools & JBPM to coexist in the same knowledge session because of race conditions between them competing for their shared resources? I'm afraid so.. :(<br>
<br> If it is so, Are there any plans for the integration of a shared JPA persistence management of both Drools & JBPM, wich may be the solution for this problem? ... Will we be better thinking to change our architecture ASAP?<br>
<br>Greets,<br><br clear="all">Alberto R. Galdo<br><a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.com</a><br><br><br><div class="gmail_quote">On Tue, May 29, 2012 at 1:54 PM, Mauricio Salatino <span dir="ltr"><<a href="mailto:salaboy@gmail.com" target="_blank">salaboy@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok, so what is happening is that two or more threads are fighting for the resources, causing that two or more transactions wants to be completed, but just one can win. All the other must be retried. Are you seeing rolled back exceptions in your stack trace? <div>
My question to you is if you really need to handle everything in just one big persistent session. I've solved similar issues in the past using more than one session, for example one session to run business processes(persistent) and one or more for receiving and reacting to events. If you have an async way to communicate both sessions there should be no problem.</div>
<div>Hope it helps!</div><div>Cheers<br><br><div class="gmail_quote"><div><div class="h5">On Tue, May 29, 2012 at 7:30 AM, Alberto R. Galdo <span dir="ltr"><<a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">Hi all,<br><br> 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..<br>
<br> 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.<br>
<br> 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.<br><br> 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 ):<br>
<br><pre><div> <span>public</span> <span>void</span> <span>clearProcessInstances</span><span>()</span> <span>{</span></div><div>
<span>for</span> <span>(</span><span>ProcessInstance</span> <span>processInstance:</span> <span>new</span> <span>ArrayList</span><span><</span><span>ProcessInstance</span><span>>(</span><span>processInstances</span><span>.</span><span>values</span><span>()))</span> <span>{</span></div>
<div> <span>((</span><span>ProcessInstanceImpl</span><span>)</span> <span>processInstance</span><span>).</span><span>disconnect</span><span>();</span></div>
<div> <span>}</span></div><div> <span>}</span></div></pre> <br> So, Drools decides to disconnect all process instances in it's JPA context without taking in account the state the process is in, and when an processinstance that is not stopped gets removed then JBPM finds it's NullPointerException...<br>
<br> We've modified the code to make Drools aware of the state of the process before wiping it from the context ( no problem here, there will be no leak as a running processinstance will be removed in future calls of "clearProcessInstances" given the process is closed ). But unfortunatelly this seems to resolve this problem, but lots of other problems ( wich seems also race conditions arise : for instance: Drools closes connections to the database and JBPM finds the connection closed, <br>
<br><br> So, we are really worried about using Drools & JBPM in a persisted environment. Maybe our asumptions are wrong... Is it possible to have an scenario like ours given the current Drools & JBPM integration status for a persistent statefulKnowledge Session? Did anyone build a complex event processing system like ours in a unaltered persistence environment such as provided in Drools and JBPM by default?<br>
<br><br>Greets,<br><br>[1] <a href="https://github.com/droolsjbpm/jbpm/blob/master/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/processinstance/JPAProcessInstanceManager.java" target="_blank">https://github.com/droolsjbpm/jbpm/blob/master/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/processinstance/JPAProcessInstanceManager.java</a><span><font color="#888888"><br>
<br><br><br><br><br><br clear="all">Alberto R. Galdo<br><a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.co</a><br>
</font></span><br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br> - MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><div> - Co-Founder @ <a href="http://www.jugargentina.org" target="_blank">http://www.jugargentina.org</a><br>
- Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br> <br> - Salatino "Salaboy" Mauricio -</div><br>
</font></span></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>