On 19 July 2011 13:42, Marc Heinz <marc.heinz@no-log.org> wrote:
rule "Single rule check age"
when
p : Person( age > 18 )
then
System.out.println("Single rule fired");
end
rule "Rule 1 of n"
when
p : Person( name.equals("Adam") )
then
System.out.println("Rule 1 of n fired");
end
// [...] hundred of others similar rules that will perform a check on the
// name attribute.
=================================
And with the following java code:
Person p = new Person();
p.setAge(22);
p.setName("Adam");
FactHandle fh = ksession.insert(p);
ksession.fireAllRules();
p.setAge(23);
ksession.update(fh, p);
ksession.fireAllRules();
This will actually produce the output:
Rule 1 of n fired
Single rule fired
Rule 1 of n fired
Single rule fired
So, despite I have only updated one attribute of the fact (the age of a
Person), all rules have been fired again, even if they had nothing to do
with the said attribute, which could possibly produce a huge overhead.
I maybe misunderstood some basic concept here... But is there a way to
prevent that?
For example, I expect a different behavior when using a
PropertyChangeSupport object that would fire events only for specific
fields (but I wasn't able to test it yet)...
Thanks,
Marc
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users