[jboss-jira] [JBoss JIRA] (DROOLS-526) If an Event triggers two rules, both using dynamic salience, the order is incorrect
Mario Fusco (JIRA)
issues at jboss.org
Mon Jun 16 10:07:24 EDT 2014
[ https://issues.jboss.org/browse/DROOLS-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976595#comment-12976595 ]
Mario Fusco commented on DROOLS-526:
------------------------------------
Fixed by https://github.com/droolsjbpm/drools/commit/83f80c83f
> If an Event triggers two rules, both using dynamic salience, the order is incorrect
> -----------------------------------------------------------------------------------
>
> Key: DROOLS-526
> URL: https://issues.jboss.org/browse/DROOLS-526
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 6.0.1.Final
> Reporter: Jinghai Rao
> Assignee: Mario Fusco
> Labels: backport-to-6.0.x
> Fix For: 6.1.0.Final
>
> Attachments: DynamicSalienceAndStreamMode.zip
>
>
> 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 declare lines from Sample.drl, the test will succeed.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list