[rules-users] Could anyone suggest alternate approach

Wolfgang Laun wolfgang.laun at gmail.com
Mon Nov 23 13:30:07 EST 2009


1) See previous answer.

2) All 4 rules will never be put on the agenda since the age brackets
will restrict this to 1 and 2, or 3 and 4, respectively. Having rules
put on the agenda, to be revoked by an update, is a common scenario.

The Drools engine should probably be informed about the update of the
CustomerDetail by using one of update() or modify(){..}.

-W



On 11/23/09, Lindy hagan <lindyhagan at gmail.com> wrote:
> Please ignore my previous email as I did not include subject.
>
> I have 4 drl files in my app. Loading all the 4 during application startup.
> If any rule is satisfied in File 1,I don't want File 2 be called.Should
> execute File 3 and 4.
> Similarly If rules in File 1 is not satisfied,want to call File 2 then File
> 3 and 4.
>
> At present I am doing this way.Please let me know if this is ok or if there
> is any better solution.
>
> Set an attribute when a rule is satisfied. (attribute is not dummy,I need it
> in my app)
> Attribute is checked in each and every if it is null.
>
>
> Example File1.drl contains 2 rules.If first rule is satisfied, don't want to
> execute second rule.So setting rule with a valid number.
>
>
> File1.drl
>
> rule "1.Age Factor and Junior"
>      when
>           d : CustomerDetail( rule == "" && sale == 'Junior' && age in
> ("16","17"))
>      then
>      System.out.println("Junior and Age Satisfied ");
>       d.setRule("1");
> end
>
> rule "2.Junior only Age Factor"
>      when
>           m : CustomerDetail( rule == "" && age in ("16","17"))
>      then
>       System.out.println("Only junior Age satisfied.");
>       m.setRule("2");
> end
>
>
>
> File2.drl
>
> rule "3.Age Factor and Senior"
>      when
>           d : CustomerDetail( rule == "" && sale == 'Senior' && age in
> ("70","75"))
>      then
>      System.out.println("Senior and Age Satisfied ");
>       d.setRule("10");
> end
>
> rule "4.Senior only Age Factor "
>      when
>           m : CustomerDetail( rule == "" && age in ("70","75"))
>      then
>       System.out.println("Only senior Age satisfied.");
>       m.setRule("11");
> end
>
> This one works but I see these disadvantages:
> 1)If the rule 1 is satisfied, rule2 is still executed.Similary all the rules
> in File2.drl.
> 2)Might impact performance all the 4 rules are called all time.
>
> Any suggestions?
>



More information about the rules-users mailing list