0
votes

I have a simple rule file

rule 'rule name 1'
  when
     $i: Test(param1 < 20)
  then
     $i.setStatus('Param1 has invalid value');
end

rule 'rule name 2'
      when
         $i: Test(param1 > 20)
      then
         $i.setStatus('Param2 has invalid value');
    end

rule 'rule name 3'
      when
         $i: Test(param1 == 100)
      then
         $i.setStatus('Param3 has invalid value');
    end

I use StatelessKieSession to execute a data object on the rules above.

Qn 1: What is the simplest way to trigger a method/listener after executing ALL the rules or How do we know all the rules have been executed?

Qn 2: If we can add a listener to the StatelessKieSession object is there a way to pass an object to the listener?

1
By ALL rules you mean "all of the rules defined in the DRL were executed at least one" or "all the rules that could have been executed were actually executed"?Esteban Aliverti
@Esteban, I was referring to "all the rules that could have been executed were actually executed"Jay

1 Answers

1
votes

You can obtain all rule names by inspecting the KieBase - see the API documentation.

You can set up a listener according to the API. The method that's called when a rule fires will let you register just that in a Map or similar.

Since a Listener is an object with a certain interface it can have an arbitrary constructor and/or additional methods which will let you pass arbitrary data to that Listener.