I want to implement rule engine in which if only one condition executes then it will not check other specified conditions.
rule "Print out lower-case tokens"
when
Token ( coveredText == coveredText.toLowerCase )
then
System.out.println("Found a lower case token with text");
end
rule "Print out long tokens with more than 5 characters"
when
Token ( tokenText : coveredText, end - begin > 5 )
then
System.out.println("Found a long token with more than 5 characters \"" + tokenText + "\"");
end
In above example, if coveredText and its lowercase are equals then I don't want to check another rule.
How can I implement this kind of nature in Drools Rule Engine
?
This can be achieved by using agenda groups in Drools.
Quote :
For example when rule "Print out lower-case tokens" fires, you can set the focus to another group (Not the group of the two rules you mentioned). Of course you want the first rule the be triggered first. This can be done with a higher salience value: