<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thx for your answer, Wolfgang.<br><br>While your advice makes sense, it does not help me. I cannot avoid using OR. I use Drools for validation and I have some cases when I need to use OR between conditions for evaluating an invalid state. Also, the solution you proposed works fine when the rule works with one object type only. If there are more than 1, it does not work. A workaround I see, would be to separate each of the condition from OR, into separate rule. But that adds the overhead of managing multiple rules.<br><br>In Expert, 5.1 manual, there is an example of how to chain expressions in DSL, using OR. They mention mapping OR being sensible, but I wish there were more details about that sensible thing.<br>--quote from the manual:<br>"<br>Example 4.77. Chaining DSL Expressions<br><br>&nbsp;There is a person called Bob who is happy<br>&nbsp; Or<br>There is
 a person called Mike who is sad<br>Of course this assumes that "Or" is mapped to the "or" conditional element (which is a sensible thing to do).<br>"<br>--end quote<br><br>So, my question was:&nbsp; <br>Is any solution to chain conditions using eval, without having the rule firing multiple times? From your answer, it seems not, and it seems that will not be possible due to some Rete-level refactoring or optimization (hope I got your message correct, I do not know how RETE works). Is that true? <br><br>I believe, I can live with this limitation (rule fires multiple times). I only hope that there is no other implication, that I am not aware of right now.<br><br>Thanks,<br>Patricia<br><br>--- On <b>Fri, 8/27/10, Wolfgang Laun <i>&lt;wolfgang.laun@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Wolfgang Laun &lt;wolfgang.laun@gmail.com&gt;<br>Subject: Re:
 [rules-users] Drools Guvnor: Rule fires multiple times when using eval and OR<br>To: "Rules Users List" &lt;rules-users@lists.jboss.org&gt;<br>Date: Friday, August 27, 2010, 3:32 AM<br><br><div class="plainMail">My advice is: Try to avoid the Conditional Element "or". From the<br>"Expert" manual: "The engine actually has no understanding of the<br>Conditional Element 'or',..." So, if the engine doesn't "understand"<br>it, how can we? ;-)<br><br>More seriously now, there is general consent that a CE "or" should<br>ultimately result in two (or more) disjunct (sub-)rules, firing<br>independently. But this clear strategy is apparently countered (you<br>could even say marred) by some Rete-level refactoring or optimization.<br><br>Anyway, in your case, a "healthy" solution is to write<br><br>rule "any blank"<br>when<br>&nbsp; &nbsp; Asset( eval( StringUtil.isBlank(name) || StringUtil.isBlank(tag)
 ))<br>then<br>&nbsp;&nbsp;&nbsp;//...<br>end<br><br>-W<br><br><br>2010/8/27 Patricia Bogoevici &lt;<a ymailto="mailto:patriciabogoevici@yahoo.com" href="/mc/compose?to=patriciabogoevici@yahoo.com">patriciabogoevici@yahoo.com</a>&gt;<br>&gt;<br>&gt; Hi all,<br>&gt;<br>&gt; I am using Drools Guvnor 5.1. I created a rule that uses eval, and OR for conditions. When I tested the rule, I noticed in the log, that actually the rule fired twice.<br>&gt; The error seemed to be caused by eval and or combination. When I re-wrote the rule to not use eval, it fired only once. Also, I re-wrote the rule to use eval, but AND for conditions, again, the rule fired once as expected.<br>&gt; I wonder if there is any other rule attribute besides no-loop, and lock-on-active that I can use to not have the rule firing twice. Or if there is any way to make the rule not firing twice.The main problem for me, is that after the rule is executed, there are 2 objects
 created.<br>&gt;<br>&gt; Below is the rule test scenario, and audit log:<br>&gt;<br>&gt;<br>&gt; Rule with eval and OR, rule fires twice<br>&gt; &nbsp;&nbsp;&nbsp; rule "test_rule_1"<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lock-on-active true<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; no-loop true<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dialect "mvel"<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; when<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Asset(eval(StringUtils.isBlank(name)))<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Asset(eval(StringUtils.isBlank(tag)))<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; then<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assetfact0 = new Asset();<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fact0.setStatus( "INVALID"
 );<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insert(fact0 );<br>&gt; &nbsp;&nbsp;&nbsp; end<br>&gt;<br>&gt; Audit log:<br>&gt; OBJECT ASSERTED value:Asset( model=MODEL, status=null, tag=null, classification=null, name=null, serial=null ) factId: 1<br>&gt; FIRING rule: [test_rule_1] activationId:test_rule_1 [1] declarations:<br>&gt; OBJECT ASSERTED value:Asset( model=null, status=INVALID, tag=null, classification=null, name=null, serial=null ) factId: 2<br>&gt; FIRING rule: [test_rule_1] activationId:test_rule_1 [1] declarations:<br>&gt; OBJECT ASSERTED value:Asset( model=null, status=INVALID, tag=null, classification=null, name=null, serial=null ) factId: 3<br>&gt;<br>&gt; Rule with eval and AND, rule fires only once:<br>&gt; &nbsp;&nbsp;&nbsp; rule "test_rule_2"<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lock-on-active true<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; no-loop true<br>&gt; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; dialect "mvel"<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; when<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Asset(eval(StringUtils.isBlank(name)))<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Asset(eval(StringUtils.isBlank(tag)))<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; then<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assetfact0 = new Asset();<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fact0.setStatus( "INVALID" );<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insert(fact0 );<br>&gt; &nbsp;&nbsp;&nbsp; end<br>&gt;<br>&gt; Audit log:<br>&gt; OBJECT ASSERTED value:Asset( model=MODEL, status=null, tag=null, classification=null, name=null, serial=null ) factId: 1<br>&gt; FIRING rule: [test_rule_2] activationId:test_rule_2 [1] declarations:<br>&gt; OBJECT ASSERTED value:Asset( model=null, status=INVALID,
 tag=null, classification=null, name=null, serial=null ) factId: 2<br>&gt;<br>&gt; Rule with simple string validation instead of eval. The rule fires only once.<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp; rule "test_rule_3"<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lock-on-active true<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; no-loop true<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dialect "mvel"<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; when<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Asset(name=="''")<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Asset(tag=="'''")<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; then<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assetfact0 = new Asset();<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fact0.setStatus( "INVALID" );<br>&gt;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insert(fact0 );<br>&gt; &nbsp;&nbsp;&nbsp; end<br>&gt;<br>&gt;<br>&gt; Audit log:<br>&gt; OBJECT ASSERTED value:Asset( model=MODEL, status=null, tag=null, classification=null, name='', serial=null ) factId: 1<br>&gt; FIRING rule: [test_rule_3] activationId: test_rule_3 [1] declarations:<br>&gt; OBJECT ASSERTED value:Asset( model=null, status=INVALID, tag=null, classification=null, name=null, serial=null ) factId: 2<br>&gt;<br>&gt;<br>&gt; Thanks,<br>&gt; Patricia<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; rules-users mailing list<br>&gt; <a ymailto="mailto:rules-users@lists.jboss.org" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;<br><br>_______________________________________________<br>rules-users mailing list<br><a ymailto="mailto:rules-users@lists.jboss.org" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></div></blockquote></td></tr></table><br>