在使用 insertLogical 时停止进入流口水循环

stopping from going in to loop in drools while using insertLogical

我在 drools 中使用 insertLogical()。

规则如下:

rule "logical insert"
salience 100
    when
        $p : Person( $number : number > 1, $name : name == "AB" || name == "AC" )
        not ( exists( PersonConfig( person == $p )))
    then
        System.out.println("Inserted PC");
        insertLogical(new PersonConfig(16,$name,$p));
end

rule "Check Inserted"
salience 90
    when
        $pc : PersonConfig(  )
    then
        System.out.println("Inserted PC Object: "+$pc);
end

rule "Retract Person Config Rule When Clause"
salience 80
    when
        $p : Person( number > 1, name == "AB" || name == "AC"  )
    then
        System.out.println("Retracting : "+$p);
        //$p.setName("BD");
        //retract($p);
        update($p);
end

rule "Checking Person Config Exist"
salience 70
    when
        not ( exists( PersonConfig(  ) ))
    then
        System.out.println("PC not Exists");
end

下面我想做什么:

  1. 我正在选择所有插入的人 class 对象,并在此基础上尝试根据某些条件插入逻辑 (PersonConfig()) 对象。
  2. 现在,我正在对 Person class 对象进行一些更新,但执行 insertLogical 的条件保持不变。这导致触发规则 "logical insert"。然后我试图通过在条件

    以下放置约束来停止这次发射

    不(存在(PersonConfig(person == $p)))

即如果没有具有同一人引用的属性的 PersonConfig 对象。但它不起作用。

请检查并提供一些解决方案。

谢谢

我通过@PropertyReactive 注释找到了一种方法。通过这种方式,它按照我的预期工作。

通过@PropertyReactive注解;它正在按照我的 expectation.It 工作,没有重新激活规则 "logical insert" 并且没有进入循环。