Reputation: 6176
suppose I have added some objects
{O1,O2,O3}
and rules
{R1,R2,R3}
in my knowledgebase
when I fire all rules the execution order goes like this:
R1 <on> O1
R1 <on> O2
R1 <on> O3
R2 <on> O1
R2 <on> O2
R2 <on> O3
R3 <on> O1 (add to passed object cache)
R3 <on> O2 (add to passed object cache)
R3 <on> O3 (add to passed object cache)
This means I can't put the passed objects in a cache until the last loop
how to change the execution order to:
R1 <on> O1
R2 <on> O1
R3 <on> O1 (add to passed object cache)
R1 <on> O2
R2 <on> O2
R3 <on> O2 (add to passed object cache)
R1 <on> O3
R2 <on> O3
R3 <on> O3 (add to passed object cache)
Upvotes: 0
Views: 400
Reputation: 84
From the Drools Expert User Guide, section 4.3.4.2:
As a general rule, it is a good idea not to count on rules firing in any particular order, and to author the rules without worrying about a "flow".
Even the execution order you've seen is not guaranteed. The example seems to be about imperative style control in the sense of "first do this, then do this, then put the object somewhere." A rule engine is the wrong tool for this job, programming languages like Java are better suited for fine control over loops and such.
Upvotes: 1