[jboss-jira] [JBoss JIRA] (DROOLS-1478) Call ActivationUnMatchListener also when a rule rematches

Mario Fusco (JIRA) issues at jboss.org
Fri Mar 24 13:36:00 EDT 2017


     [ https://issues.jboss.org/browse/DROOLS-1478?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mario Fusco resolved DROOLS-1478.
---------------------------------
    Fix Version/s: 7.0.0.Beta8
       Resolution: Out of Date


Replaced by https://issues.jboss.org/browse/DROOLS-1497

> Call ActivationUnMatchListener also when a rule rematches
> ---------------------------------------------------------
>
>                 Key: DROOLS-1478
>                 URL: https://issues.jboss.org/browse/DROOLS-1478
>             Project: Drools
>          Issue Type: Enhancement
>          Components: core engine
>            Reporter: Geoffrey De Smet
>            Assignee: Mario Fusco
>             Fix For: 7.0.0.Beta8
>
>
> ActivationUnMatchListener is part of kie-internal, so its *not public API*.
> *ActivationUnMatchListener is only used by OptaPlanner* (probably):
> jBPM and downstream drools module don't use it:
>   https://github.com/search?q=org%3Akiegroup+ActivationUnMatchListener&type=Code
> Community users probably don't use it either, because no one mentions it on StackOverflow:
>   https://www.google.be/search?q=%2BActivationUnMatchListener+site:stackoverflow.com&*
> ----
> The current behaviour of ActivationUnMatchListener is a pain because it doesn't unmatch if a RHS fires again, causing an imbalance. OptaPlanner works around this through a hack (which fails for PLANNER-761).
> For example, given this rule
> {code}
> global int score = 0;
> rule R
> when
>     Wine(age < 10, $age : age)
> then
>     score += $age;
>     addUnmatchListener(() -> score -= $age);
> end
> {code}
> This works for a normal match and unmatch event:
> {code}
> Wine w = new Wine(3);
> insert(w);
> fireAllRules(); => score = 7;
> w.age = 50;
> update(w);
> fireAllRules(); => unmatch triggers => score = 0; // GOOD
> {code}
> So events are like this:
> {code}
> RHS
> unmatch
> {code}
> However if we have a rematch:
> {code}
> Wine w = new Wine(3);
> insert(w);
> fireAllRules(); => score = 7;
> w.age = 4;
> update(w);
> fireAllRules(); => no unmatch triggers => score = 13; // BAD Should be 6. Unmatch should have triggered.
> w.age = 50;
> update(w);
> fireAllRules(); =>  unmatch triggers => score = 7; // Should be 0.
> {code}
> Because the events are unbalanced:
> {code}
> RHS
> RHS
> unmatch
> {code}
> I'd argue that anyone using the ActivationUnMatchListener would want to the have balanced events. 



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list