[rules-users] Can we fire a rule from another rule...?

Ross H rossh00 at gmail.com
Fri Dec 4 04:57:10 EST 2009


Good point. I've been using this in a couple of my solutions and was worried
that I was creating implicit dependencies, ie. you need to assume Rule 2 is
there. I also find that it can complicate the rules to ensure firing is
correct or avoid looping.

I assume your saying the conditions of Rule 1 should be rewritten to
accommodate Rule 2, and given the various conditions Rule 1 may actually be
split into multiple rules that may call the RHS (now a function) of Rule 2
depending on conditions.

On the other hand is there not a case for building up a knowledge base of
facts that rules can act on. How do you separate these situations.

2009/12/4 Wolfgang Laun <wolfgang.laun at gmail.com>

> I have some reservations w.r.t. the proposed solution. One has to assume
> that "Rule 2" is there (and should continue to be so) to fire when its
> condition is true, irrespective of what goes on due to "Rule 1". The only
> way to do this is by writing
>    InsertedFact()
>    or
>    condition-of-rule2()
> and this would make any bindings in condition-of-rule2() unusable in the
> rule's consequence.
>
> If by "firing" is meant that the RHS of Rule 2 is to be executed, simply
> add the statements of the consequence to the ones of Rule 1. (Wrapping it in
> a function avoids code duplication.)
>
> -W
>
>
>
> 2009/12/4 Ross H <rossh00 at gmail.com>
>
> Insert a new fact that causes Rule 2 to fire. That way you can decouple
>> your logic and gain more flexibility to add more rules based on this new
>> fact.
>>
>> 2009/12/4 Deepak Jambhekar <deepak.jambhekar at tcs.com>
>>
>>> Hi...
>>>        In one of my requirments I need to fire a rule from another
>>> rule... i.e.
>>>  when
>>>       rule "Rule 1"
>>>
>>> when
>>>
>>> condition()
>>>
>>> then
>>>
>>>       someaction()
>>>
>>>       then it should fire another rule Rule2
>>>
>>> end
>>>
>>>           rule "Rule 2"
>>>
>>> when
>>>
>>>  condition()
>>>
>>> then
>>>
>>>       someaction()
>>>
>>> end
>>> Can we achieve this in Guvnor??
>>> please help....
>>>
>>> Thanks
>>> Deepak Prabhakar Jambhekar
>>>
>>> =====-----=====-----=====
>>> Notice: The information contained in this e-mail
>>> message and/or attachments to it may contain
>>> confidential or privileged information. If you are
>>> not the intended recipient, any dissemination, use,
>>> review, distribution, printing or copying of the
>>> information contained in this e-mail message
>>> and/or attachments to it are strictly prohibited. If
>>> you have received this communication in error,
>>> please notify us by reply e-mail or telephone and
>>> immediately and permanently delete the message
>>> and any attachments. Thank you
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091204/ebd4098b/attachment.html 


More information about the rules-users mailing list