<p>Hello,</p>
<p>I am involved in a project in which we are using Drools as the BPM.</p>
<p>We are experiencing some problems with wait state nodes. More concretely, the problem seems to deal with<br>the execution of constraints in those wait states.</p>
<p>Let me first describe our context:</p>
<p>We are using JPA with Hibernate and Oracle. Our process instances are all identified by a<br>business identifier (a string). This business identified would correspond to the identifier of a case;<br>and a case normally has associated a process instances (and subprocesses of that process).</p>

<p>Additionally, the processes we have developed make extensive<br>use of timers and wait states with constraints that refer to the process instance and other facts that<br>we are using as events.</p>
<p>We have a stateful session for every case / business identifier.</p>
<p>We have a main process that calls subprocesses. As we said, in that process and subprocesses we use wait states.<br>The constraints in those wait states are &quot;waiting&quot; for a fact to be inserted in the stateful session. Once<br>
the corresponding fact is inserted, the corresponding constraint should be activated.</p>
<p>At this point is where the problem arises. All the constraints have been unit tested with no problem at all.</p>
<p>But we have detected some problems that can arise when there is more that one process waiting in the same wait state<br>(every process in a different Drools stateful session).</p>
<p>The situation is as follows:</p>
<p>1. There is a main process instance MPA with business id BA that has a subprocess SPA (also with the same business id).<br>This subprocess is waiting in a given wait state W1 (these processes are running in the stateful<br>
session corresponding to the business id BA, from now on SA).</p>
<p>2. There is a second main process and subprocess with business id BB. The state for these second set of processes is the<br>same one, and they are running in a second stateful session (the one for business id BB), from now on SB.</p>

<p>3. A fact FA is inserted in SA. This fact makes the constaint in SPA true, which makes SPA to leave the wait<br>state and continue with the execution.</p>
<p>Then, in some situations stateful session SA tries to also continue SPB, which runs in a different stateful session<br>(that of SB). That, of course, produces some posterior problems that were the origin of our investigations.</p>

<div>After some more deep investigations, it seems that the reason session SA tries to continue SPB is that the constraint<br>in W1 for SPA gets activated twice. We have detected (and posteriorly corrected) some situations in which this happens.</div>

<div> </div>
<div>For example: the process in the constraint was associated not only to SPA but to other processes in SA (the main process SPA for example).<br>we corrected this and obtained a better behaviour in which the problem is more difficult to reproduce.</div>

<p>We have tried also to replace constraints with rule nodes, and set the lock-on-active and no-loop. The results were a bit different<br>but seemed not to avoid the problem.</p>
<p>So, there is someone that has experimented situations similar to the described above? Additionally, can someone from the drools<br>team give a bit of light to this situation? Why the reasonings in a stateful session are interacting with processes running on a different<br>
stateful session?</p>
<p>many thanks in advance,<br>Jordi Alvarez<br></p>