[rules-users] Possible problem in PathMemory

Michael Anstis michael.anstis at gmail.com
Fri Jun 13 19:22:56 EDT 2014


I could be wrong but I thought dynamic salience used facts in working
memory and hence your RHS would need to signal changes to the salience
variables.

Sent on the move
On 14 Jun 2014 00:01, <raojinghai at gmail.com> wrote:

> Hi Mario,
>
> I figured out this is a problem with Event and dynamic salience. Suppose
> we have the following declarations and rules:
>
> declare Message
>     @role(event)
> end
>
> rule "rule1"
> salience RuleSalience.RULE1
> when
>     $m : Message()
> then
>     System.out.println("====================> rule1");
>     retract($m);
>     RuleSalience.RULE1 = RuleSalience.RULE2 - 1;
> end
>
> rule "rule2"
> salience RuleSalience.RULE2
> when
>     $m : Message()
> then
>     System.out.println("=====================> rule2");
>     retract($m);
>     RuleSalience.RULE2 = RuleSalience.RULE1 - 1;
> end
>
> I want when a Message is inserted, either rule1 or rule2 is fired. I also
> want two rules can fire alternatively. So when one rule is fired, its
> salience becomes lower.
>
> The result is, if I don't declare Message as an Event, it works fine.
> Otherwise, only rule1 is fired.
>
> The problem seems to be at
> org.drools.core.reteoo.LeftInputAdapterNode::doInsertSegmentMemory().
> Because of stream mode, both rules are not inserted StagedLeftTuples. So
> rule1 and rule2 are not compared based on salience. Because rule1 has a
> smaller act#, it is always fired first.
>
> The attached zip is a test case. If you want mvn clean test, it will fail.
> However, if you remove the following lines from Sample.drl, the test will
> succeed.
>
> "declare Message
>     @role(event)
> end"
>
> Thanks.
>
> Jinghai
>
> _______________________________________________
> 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/20140614/05393cd2/attachment-0001.html 


More information about the rules-users mailing list