Michael is right. It is just harder to explain than to do it. Just take a look at agenda-groups or ruleflow-groups. Chose which one you prefer to use it, place your rules in two separate groups: A and B.

    If using agenda-groups, set initial focus to A, fireAllRules and make sure that on the consequence of one of the rules from group A you set focus to B. So if that rule never fires, B will never have the focus and will never fire. Just remeber that agenda-groups work like a stack, so if you want ALL rules from A to execute before B, add the setFocus on the rule with the lowest salience in A.

    Using ruleflow-groups is similar, but you draw your "flow" graphically, and it does not work like a stack. Sometimes easier for your use case.

    []s
    Edson

2009/1/21 Anstis, Michael (M.) <manstis1@ford.com>
Hi,

See below.

"executing a rule" is really two parts: LHS pattern matching (which
can't be stopped for a given RuleBase) and execution of the RHS (which
can be controlled by the agenda and truth maintenance).

I hope my time away hasn't led to me giving wrong advice.

Mike

-----Original Message-----
From: rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Thierry B
Sent: 21 January 2009 12:53
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Run a set of rules in a group B from a rule
in agroup A


Hello,

So if I've well understand :

- before calling fireAllRules(), Drools know for all rules (from any
group)
definied in DRL files, those which all patterns in the LHS of a rule are
matched, and those rules are placed on a agenda.

At which moment exactly, Drools verified from a rule that all of its
pattern
in the LHS are matched, if it's before callling fireAllRules() ?

>>> Yes, LHS is evaluated on workingMemory.insert(o). A call to
fireAllRules() executes the activations on the agenda (i.e. RHS queued
as a consequence of LHS being matched on workingMemory.insert(o)).

- And fireAllRules() permit to execute all rules that are placed on
agenda

>>> Yes

- When using setFocus() from a java class or a rule, we can control the
order of rules to specify to execute rules from group B, and group C...

>> I believe so.

- So it's not possible to tell Drools that we don't want to execute a
group
of rules if a rule A is not matched : in that group of rules : those
which
all paterns match LHS will be inevitably executed.

>>> Wrong. The rules won't be executed (read as activations - RHS -
won't be run) but you can't stop the LHS being evaluated.

All these points that I said, are exact?

Thanks :-)


Anstis, Michael (M.) wrote:
>
> Please accept that my knowledge is based on 4.x and there might be
other
> alternatives in 5.
>
> Rules are not "ran" but their patterns (LHS) evaluated as facts
> (objects) are inserted into Working Memory. When all patterns in the
LHS
> of a rule are matched activations are placed on the agenda for
execution
> of the consequence (RHS) when fireAllRules() is called (or other
> mechanisms to run what is on the agenda are invoked; such as
RuleFlow).
> So you could have rules in Group A cause Group B to receive the focus
> but it is the RHS's execution order you control and not the pattern
> matching - which will happen for Group A and Group B when facts are
> inserted into WM.
>
> Look at Agenda Groups and RuleFlow. This should help.
>
> With kind regards,
>
> Mike
>
>

--
View this message in context:
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
roup-A-tp21580767p21582595.html

Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com