I have actually used this method for the one valid case I have thought of -
unit testing rules.
Steve
2011/4/1 Swindells, Thomas <TSwindells(a)nds.com>
Agreed,
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.
Thomas
*From:* rules-users-bounces(a)lists.jboss.org [mailto:
rules-users-bounces(a)lists.jboss.org] *On Behalf Of *Michael Anstis
*Sent:* 31 March 2011 10:08
*To:* Rules Users List
*Subject:* Re: [rules-users] execute particular rules programmatically and
dynamically
Why would you want to execute a single rule?
The logic you'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 "Smurf"
then write a rule that matches on "Smurf". When you insert a "Smurf"
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 "polluting" the results you
expect to see?
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.
If you give your use-case we might be able to advise a better approach.
With kind regards,
Mike
2011/3/31 Wolfgang Laun <wolfgang.laun(a)gmail.com>
On 31 March 2011 07:58, Benson Fung <benson.redhat(a)gmail.com> wrote:
Hi,
If there are 10 rules in the drools rulebase, and right now I would
like to execute one of the particular rule. Is there any approach/way
to execute particular rule programmatically?
No. The right hand side of a rule (code between "then" and "end") 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.
I don't think
agenda-group or activation-group can do that, right? Or is it
possible to create an agenda programmatically ?
No to both.
-W
Thanks
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
------------------------------
**************************************************************************************
This message is confidential and intended only for the addressee. If you
have received this message in error, please immediately notify the
postmaster(a)nds.com 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.
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
**************************************************************************************
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users