Thebrothbobo
Thebrothbobo

Reputation: 1

How to loop in business process Drools

I'm looking for weeks now to find the answer, and I definitely need help !!

Here is my enquiry.

I've build up a business process with many business rules, but I would like inside one rule to evaluate a variable and if this variable is false, I would like to loop back to my first rules flow to re-execute de sequence.

My problem: I found the XOR gateway and I tried to implement my condition within outcoming arrows but the variable I want to assess isn't yet existing.

How could I create a global variable that I can change while rules are fired?

Thanks a lot in advance for anyone trying to help!

Let me know if I've been unclear, of you need further information

Upvotes: 0

Views: 97

Answers (1)

Mykhaylo Adamovych
Mykhaylo Adamovych

Reputation: 20976

You are trying to think in terms of global variables.
I encourage you to think in terms of event driven development. Drools is about facts and events which has really minor differences.
You are saying that 'under certain conditions' you need to 'trigger the rule' which has its own triggers. So I would implement it this way:

  1. 'Under certain conditions' rule should insert 'dedicated event' which reflect 'the state', what have happened/changed.
  2. 'First rule' will now have 'additional trigger option' - newly created event.
  3. Don't forget to retract the event as soon as it did it's job or use automatic retraction

Upvotes: 1

Related Questions