Globals should only be used for data that is constant over the life of the working memory, which is not so in your case.
Maybe you should just use a fact counter. If you don't want to affect your code you could insert it in a separate rule.
when
then
Hello,
I would like to take 100 sampling facts for rule and persist it in the db
and ignore other data.
How Can I maintain the counter? as global variable? Please clarify with
sample code.
I tried following way and but it does not work as expected.
Ex:
global Integer counter;
rule "get sampling data"
when fact : Foo(some condition) && eval(counter <= 100)
then
counter++
// do some condition
end
--
View this message in context: http://www.nabble.com/having-counter-in-drl-tp20904469p20904469.html
Sent from the drools - user mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users