How does DRL key "insert" in rule conditions works with RuleUnit in Drools?

64 views Asked by At

I am currently in the migration process from drools 7 to drools 8. We have classic rules that do stuff like :


flow : init task --- main task 

rule init
flow init task
if 
   evaluation()
then
insert new fact1()
insert new fact2().

rule fact1
flow main task

if 
   fact1
then
   println(fact1)

Once facts were added in the working memory, they were persistent for the whole process (ie in wm in each task of the process flow).

We're on our way to use RuleUnit as recommended in the doc and we have migrated the global objects in RuleUnit.


rule init
flowtask init

if 
   /evaluation()
then
insert new fact1()
insert new fact2().



rule fact1
flowtask main
if 
   fact1 ??????
then
   println(fact1)

However, it seems the facts1 wm is lost between process tasks in drools 8 : ie fact1 and fact2 cannot be found in main task when added in wm using insert in "init task".

It seems we have to add the fact in another RuleUnit for the 2nd flow main task.

The question we have is then :
how can we transfer object from RuleUnit (init task) to RuleUnit (main task)

  • using the insert ?
  • should the insert be forgotten in drools 8 when using RuleUnit ? and only navigation via RuleUnit used ? (ie add facts to RuleUnit not via insert).

Is there a doc that explains exactly the topic of insert sentences migration from drools 7 to 8 ?

0

There are 0 answers