Hello,
I am involved in a project in which we are using Drools as the BPM.
We are experiencing some problems with wait state nodes. More concretely,
the problem seems to deal with
the execution of constraints in those wait states.
Let me first describe our context:
We are using JPA with Hibernate and Oracle. Our process instances are all
identified by a
business identifier (a string). This business identified would correspond to
the identifier of a case;
and a case normally has associated a process instances (and subprocesses of
that process).
Additionally, the processes we have developed make extensive
use of timers and wait states with constraints that refer to the process
instance and other facts that
we are using as events.
We have a stateful session for every case / business identifier.
We have a main process that calls subprocesses. As we said, in that process
and subprocesses we use wait states.
The constraints in those wait states are "waiting" for a fact to be inserted
in the stateful session. Once
the corresponding fact is inserted, the corresponding constraint should be
activated.
At this point is where the problem arises. All the constraints have been
unit tested with no problem at all.
But we have detected some problems that can arise when there is more that
one process waiting in the same wait state
(every process in a different Drools stateful session).
The situation is as follows:
1. There is a main process instance MPA with business id BA that has a
subprocess SPA (also with the same business id).
This subprocess is waiting in a given wait state W1 (these processes are
running in the stateful
session corresponding to the business id BA, from now on SA).
2. There is a second main process and subprocess with business id BB. The
state for these second set of processes is the
same one, and they are running in a second stateful session (the one for
business id BB), from now on SB.
3. A fact FA is inserted in SA. This fact makes the constaint in SPA true,
which makes SPA to leave the wait
state and continue with the execution.
Then, in some situations stateful session SA tries to also continue SPB,
which runs in a different stateful session
(that of SB). That, of course, produces some posterior problems that were
the origin of our investigations.
After some more deep investigations, it seems that the reason session SA
tries to continue SPB is that the constraint
in W1 for SPA gets activated twice. We have detected (and posteriorly
corrected) some situations in which this happens.
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).
we corrected this and obtained a better behaviour in which the problem is
more difficult to reproduce.
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
but seemed not to avoid the problem.
So, there is someone that has experimented situations similar to the
described above? Additionally, can someone from the drools
team give a bit of light to this situation? Why the reasonings in a stateful
session are interacting with processes running on a different
stateful session?
many thanks in advance,
Jordi Alvarez