In executable model, property reactivity does not work correctly when bound variables are passed to a method used in constraints of the rule.

Solution Unverified - Updated -

Issue

When we execute rules like (*1) and Java code like (*2) below, more specifically, if the pattern (*1-1) has a method call in its constraint and a bound variable is passed to the method, an unexpected infinite loop between "Rule 1" and "Rule 2" occurs only in executable model.

(*1) Example rules

rule "Rule 1"
   when
       $fact1 : Fact1( $id1 : id == 1 )
       $fact2 : Fact2( $id2 : id == 2, convertToIdString($id2) == "id2" )    ..... (*1-1)
   then
       System.out.println("***** Action of " + drools.getRule().getName());

       modify($fact1) {
           value = $id2
       }
end

rule "Rule 2"
   when
       $fact1 : Fact1( $id1 : id == 1, value == 2 )
       $fact2 : Fact2( $id2 : id == 2 )
   then
       System.out.println("***** Action of " + drools.getRule().getName());

       modify($fact2) {
           value = $id1
       }
end

(*2) Java code

KieServices kServices = KieServices.Factory.get();
KieContainer kContainer = kServices.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession();

Fact1 fact1 = new Fact1();
fact1.setId(1);
fact1.setValue(1);
kSession.insert(fact1);

Fact2 fact2 = new Fact2();
fact2.setId(2);
fact1.setValue(2);
kSession.insert(fact2);

System.out.println("***** start");
kSession.fireAllRules(10);
System.out.println("***** end");

Environment

  • Red Hat Decision Manager (RHDM)
    • 7.10+

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content