I have actually used this method for the one valid case I have thought of - unit testing rules.<div><br></div><div>Steve<br>
<br><br><div class="gmail_quote">2011/4/1 Swindells, Thomas <span dir="ltr">&lt;<a href="mailto:TSwindells@nds.com">TSwindells@nds.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">






<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Agreed,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">But if you really do want to you can setup an agenda filter so that only the activation for the rule you care about is fired – but I don’t think there are many
 valid cases where this is needed/desirable/appropriate.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thomas</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt">From:</span></b><span lang="EN-US" style="font-size:10.0pt"> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>]
<b>On Behalf Of </b>Michael Anstis<br>
<b>Sent:</b> 31 March 2011 10:08<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] execute particular rules programmatically and dynamically</span></p>
</div>
</div><div><div></div><div class="h5">
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Why would you want to execute a single rule?<br>
<br>
The logic you&#39;d write to determine which rule to fire should itself be part of the rules: So, for example, if you want to validate facts of type &quot;Smurf&quot; then write a rule that matches on &quot;Smurf&quot;. When you insert a &quot;Smurf&quot; only the rules that match on this will
 become candidates for execution when you call fireAllRules. Perhaps use of a stateless session would simplify things so you need not worry about other facts in WM &quot;polluting&quot; the results you expect to see?
<br>
<br>
More and more questions are posted here asking how to make individual rules execute; IMO the solution is to change your thinking about how Rules Engines work.<br>
<br>
If you give your use-case we might be able to advise a better approach.<br>
<br>
With kind regards,<br>
<br>
Mike</p>
<div>
<p class="MsoNormal">2011/3/31 Wolfgang Laun &lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</p>
<p class="MsoNormal" style="margin-bottom:12.0pt"> </p>
<div>
<div>
<p class="MsoNormal">On 31 March 2011 07:58, Benson Fung &lt;<a href="mailto:benson.redhat@gmail.com" target="_blank">benson.redhat@gmail.com</a>&gt; wrote:</p>
<p class="MsoNormal">Hi,<br>
<br>
If there are 10 rules in the drools rulebase, and right now I would<br>
like to execute one of the particular rule.  Is there any approach/way<br>
to execute particular rule programmatically?</p>
</div>
<div>
<p class="MsoNormal"><br>
No. The right hand side of a rule (code between &quot;then&quot; and &quot;end&quot;) is executed whenever there is a set of fact objects in Working Memory satisfying the condition. If you insert such a set of facts and call fireAllRules(), then it will happen.<br>

<br>
 </p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"> I don&#39;t think<br>
agenda-group or activation-group can do that, right?  Or is it<br>
possible to create an agenda programmatically ?</p>
</blockquote>
</div>
<div>
<p class="MsoNormal"><br>
No to both.<br>
<span style="color:#888888">-W<br>
 </span></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"><br>
Thanks<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></p>
</blockquote>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></p>
</div>
<p class="MsoNormal"> </p>
</div></div></div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the <a href="mailto:postmaster@nds.com" target="_blank">postmaster@nds.com</a> and delete it from your system as well as any copies. The content of e-mails as well as traffic data
 may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font>
</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></div>