If your problem is performance, don&#39;t worry. Conditions evaluation is shared, so in the second rule you won&#39;t re-evaluate the entire working memory (to know more:<a href="http://www.drdobbs.com/184405218">http://www.drdobbs.com/184405218</a>).<br>
<br>If you&#39;re worried about not having to repeat the conditions on the second rule, I would create inferred facts when the first rule matches and use then in the second rule + the additional conditions.<br><br>Something like:<br>
<br><p class="MsoNormal"><span lang="EN-US">Rule1:</span></p>

<p class="MsoNormal"><span lang="EN-US">when</span></p>

<p class="MsoNormal"><span lang="EN-US">            customer:Customer(town==&quot;London&quot;)</span></p>

<p class="MsoNormal"><span lang="EN-US">then</span></p>

<p class="MsoNormal"><span lang="EN-US">            insert new LondonCustomer( customer );<br></span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Rule2:</span></p>

<p class="MsoNormal"><span lang="EN-US">when</span></p>

<p class="MsoNormal"><span lang="EN-US">            london : LondonCustomer(customer.job==&quot;TEACHER&quot;)</span></p>

<p class="MsoNormal"><span lang="EN-US">then</span></p>

<p class="MsoNormal"><span lang="EN-US">            System.out.println(london.customer.getLname()
+ &quot; is a teacher&quot;);</span></p><br><br><div class="gmail_quote">2010/10/12 Dominik Hüttner <span dir="ltr">&lt;<a href="mailto:d.huettner@tiq-solutions.de">d.huettner@tiq-solutions.de</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">









<div link="blue" vlink="purple" lang="DE">

<div>

<p class="MsoNormal"><span lang="EN-US">Hello
everyone,</span></p>

<p class="MsoNormal"><span lang="EN-US">I’ve
got a question. I’m using drools-guvnor to execute some rule-scenarios. I
have to solve the following problem: I have an amount of objects in my working
memory and can’t remove objects from the working memory in the then-part
of the rule. I want to combine two rules, the first rule selects some objects
and the second rule checks only these selected objects for additional criteria.
I have to use two rules, because I want to report the objects selected in the
first rule, too. Now I have implemented this with two rules and in the second
rule, the criterias of the first rule are copied to the second rule, my
question is, is there a way to get rid of this redundandance?</span></p>

<p class="MsoNormal"><span lang="EN-US">I
have tried this with a rule flow, but the problem is, this always works on the
whole working memory, but I can’t remove the not used objects from
working memory for performance reasons. Is there another way to solve this
problem?</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Here
is an example for what I intend to do:</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Rule1:</span></p>

<p class="MsoNormal"><span lang="EN-US">when</span></p>

<p class="MsoNormal"><span lang="EN-US">            customer:Customer(town==&quot;London&quot;)</span></p>

<p class="MsoNormal"><span lang="EN-US">then</span></p>

<p class="MsoNormal"><span lang="EN-US">            System.out.println(customer.getLname()
+ &quot; is inhabitant of London&quot;);</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Rule2:</span></p>

<p class="MsoNormal"><span lang="EN-US">when</span></p>

<p class="MsoNormal"><span lang="EN-US">            customer:Customer(town==&quot;London&quot;,job==&quot;TEACHER&quot;)</span></p>

<p class="MsoNormal"><span lang="EN-US">then</span></p>

<p class="MsoNormal"><span lang="EN-US">            System.out.println(customer.getLname()
+ &quot; is a teacher&quot;);</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">This
example illustrates, with the first rule I want to get to know, how many
customers are from London and in the second rule I want to know, how many of
the London customers are teachers. I want to create a kind of statistics. I
have quite a lot of conditions for the first rule, so I don’t want to
have them redundantly.</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Greetings,
Dominik</span></p>

</div>

</div>


<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto: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>
<br></blockquote></div><br>