[rules-users] Re: looping problem

Michal Bali michalbali at gmail.com
Wed Sep 10 11:30:15 EDT 2008


Hi Thomas,

A quick solution would be to use agenda groups as follows:

rule "Rule Init"
 dialect "java"
    when
        ...
    then
        ...
        drools.setFocus("calculate");
end

rule "Rule 1"
 dialect "java"
 lock-on-active true
 agenda-group "calculate"
    when
        ...
    then
        ...
end

rule "Rule 2"
 dialect "java"
 lock-on-active true
 agenda-group "calculate"
    when
       ...
    then
       ...
end

The result is:
Rule Init
Rule 2
Rule 1

You can also use ruleflow (ruleflow-group) to achieve this. I think it is
the preferred way.
Hope it helps.

Best Regards,
Michal

On Wed, Sep 10, 2008 at 2:10 PM, thomas kukofka <thomaskukofka at web.de>wrote:

> Hello,
>
> thanks for your quick reply.
> I understand your explanation, but adding the *lock-on-active rule
> attribute to rule 1 and 2 only results that none of these rules is executed.
> What I want to be excuted for the values below:
> *            TestObject io = new TestObject(TestObject.Type.INPUT);
>             io.setDoublePropertyValue(TestObject.PARAMETER1, 0.2);
>
>             TestObject io2 = new TestObject(TestObject.Type.INPUT);
>             io2.setDoublePropertyValue(TestObject.PARAMETER1, 7.3);
>
>             insert(io);
>             insert(io2);
>             fireallrules();
>
> is:
> *Rule Init
> Rule 1
> Rule 2
> *
> Best Regards
> Thomas
>
> *Hi,
>
> Looking at the .drl file, rules 1,2 are updating objects that are part of
> their conditions. That will loop even with no-loop set to true.
>
> Look at lock-on-active rule attribute, which may solve your issue.
>
> Best Regards,
> Michal*
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080910/91667668/attachment.html 


More information about the rules-users mailing list