[rules-users] Lock-on-active and ruleflow-group

Wolfgang Laun wolfgang.laun at gmail.com
Tue Aug 9 07:21:49 EDT 2011


Modules (=agenda-group and ruleflow-group) are fine for large-scale
rule flow control. First choice for fine-grained rule execution
control is - Logic.

Write your constraints so that only one rule fires, e.g., by testing
price == null.

Ideally, you should also avoid salience by fully describing the cases
for prices 1 and 2.

Using flow control and salience - this isn't rule based programming
any more, just a very elaborate way of implementing sequential logic.

-W



On 9 August 2011 13:08, bitter <rgorzkow at gmail.com> wrote:
> But when I use activation-group only one fact has price. I would like to
> insert two facts (or more) and only one rule invoke per fact.Like in my test
> class.
> Could you look at use case that I attached in my first post? Thanks.
>
>
> Wolfgang Laun-2 wrote:
>>
>> You should use activation-group "price" or similar, not lock-on-active.
>> -W
>>
>>
>> On 9 August 2011 11:40, Wolfgang Laun &lt;wolfgang.laun at gmail.com&gt;
>> wrote:
>>>
>>> "Whenever a ruleflow-group becomes active [...], any rule within that
>>> group that has lock-on-active set to true will not be activated any
>>> more." (Emphasis added by me.)
>>>
>>> Do you activate the ruleflow-group before you insert the Car fact?
>>>
>>> -W
>>>
>>>
>>> On 9 August 2011 11:05, bitter &lt;rgorzkow at gmail.com&gt; wrote:
>>>>
>>>> Log:
>>>>
>>>> ==>[BeforeActivationFiredEvent:  getActivation()=[Activation rule=Second
>>>> rule, act#=1, salience=25, tuple=[fact
>>>> 0:1:1428842218:1428842218:1:DEFAULT:Car{color='red', size='small',
>>>> price=null}]
>>>> ],
>>>> getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 72f6f1b6]
>>>> ==>[AfterActivationFiredEvent: getActivation()=[Activation rule=Second
>>>> rule,
>>>> act#=1, salience=25, tuple=[fact
>>>> 0:1:1428842218:1428842218:2:DEFAULT:Car{color='red', size='small',
>>>> price=2}]
>>>> ],
>>>> getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 72f6f1b6]
>>>> ==>[BeforeActivationFiredEvent:  getActivation()=[Activation rule=First
>>>> rule, act#=0, salience=20, tuple=[fact
>>>> 0:1:1428842218:1428842218:2:DEFAULT:Car{color='red', size='small',
>>>> price=2}]
>>>> ],
>>>> getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 72f6f1b6]
>>>> ==>[AfterActivationFiredEvent: getActivation()=[Activation rule=First
>>>> rule,
>>>> act#=0, salience=20, tuple=[fact
>>>> 0:1:1428842218:1428842218:3:DEFAULT:Car{color='red', size='small',
>>>> price=1}]
>>>> ],
>>>> getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 72f6f1b6]
>>>> ==>[BeforeActivationFiredEvent:  getActivation()=[Activation rule=Second
>>>> step, act#=2, salience=40, tuple=[fact
>>>> 0:1:1428842218:1428842218:3:DEFAULT:Car{color='red', size='small',
>>>> price=1}]
>>>> ],
>>>> getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 72f6f1b6]
>>>> ==>[AfterActivationFiredEvent: getActivation()=[Activation rule=Second
>>>> step,
>>>> act#=2, salience=40, tuple=[fact
>>>> 0:1:1428842218:1428842218:3:DEFAULT:Car{color='red', size='small',
>>>> price=1}]
>>>> ],
>>>> getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 72f6f1b6]
>>>> Car{color='red', size='small', price=1}
>>>>
>>>> java.lang.AssertionError:
>>>> Expected :2
>>>> Actual   :1
>>>>        at org.junit.Assert.fail(Assert.java:91)
>>>>        at org.junit.Assert.failNotEquals(Assert.java:645)
>>>>        at org.junit.Assert.assertEquals(Assert.java:126)
>>>>        at org.junit.Assert.assertEquals(Assert.java:145)
>>>>        at
>>>> CarKnowledgeBaseTest.shouldObtainPriceWhereSalienceIsBigger(CarKnowledgeBaseTest.java:47)
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>        at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>        at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>        at
>>>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>>>>        at
>>>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>>>>        at
>>>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>>>>        at
>>>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>>>>        at
>>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
>>>>        at
>>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>>>>        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>>>>        at
>>>> org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>>>>        at
>>>> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>>>>        at
>>>> org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>>>>        at
>>>> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>>>>        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>>>>        at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
>>>>        at
>>>> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
>>>>        at
>>>> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
>>>>        at
>>>> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>        at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>        at
>>>> com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
>>>>
>>>> --
>>>> View this message in context:
>>>> http://drools.46999.n3.nabble.com/Lock-on-active-and-ruleflow-group-tp3237089p3238338.html
>>>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>>> _______________________________________________
>>>> 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
>>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Lock-on-active-and-ruleflow-group-tp3237089p3238587.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list