1

I need to count the number of facts satisfying a certain constraint in working memory and then fire the rule if the number of facts breaches a certain threshold. I tried the following but it is complaining about "mismatched input '$cnt' in rule "Rule1"

rule Rule1
when
    accumulate ( AFact ( code == "XXXX" ); $cnt : count(1) ; $cnt > 1 )
then
    // fire
end

Any help to get the syntax right would be appreciated. Thanks!

1 Answers1

0

The accumulate Conditional Element (as you are using) is only available in Drools versions 5.4 and later - you must be using 5.3.0 or earlier.

You can use the old form of accumulate, available as a continuation of from:

Number( intValue > 1 )
   from accumulate( AFact ( code == "XXXX" ), count(1) )
laune
  • 31,114
  • 3
  • 29
  • 42