droolsdrools-guvnordrools-plannerdrools-flowdrools-kie-server

how to add value to duration attribute in drools


Whenever i write duration(0s), it works but as soon as i change it to duration(1s) or duration(5s), the rule doesn't fire... This is the rule which i want to fire.

rule "ContainsChecking"

agenda-group "town4"

duration(0s)

when

Town(owner matches "[N || n][a-z]+")

then

System.out.println("Rule Fired ContainsChecking");

end

do we need to import something for duration attribute to work, because i m not getting it anywhere. Thanks in advance.


Solution

  • You need to run the session using

    kieSession.fireUntilHalt();
    

    If you just use fireAllRules, the agenda is empty and the call terminates.

    This is a CEP feature and need not and should not be used in a simple production rule environment.