[
https://issues.jboss.org/browse/DROOLS-164?page=com.atlassian.jira.plugin...
]
Davide Sottara commented on DROOLS-164:
---------------------------------------
Citing the Drools Expert guide:
"Whenever a ruleflow-group becomes active or an agenda-group receives the focus, any
rule within that group that has lock-on-active set to true will not be activated any more;
irrespective of the origin of the update, the activation of a matching rule is
discarded".
When you insert the fact, both rules become active. Rule 1 then fires first because of the
higher salience. When it modifies the Tradebooking AFTER setting the action (notice that
it is a key attribute!), two things happen: a new activation (with an effectively new
TradeHeader) is tentatively generated, but rejected because of the lock-on-active; the
previous activation is cancelled because its supporting facts no longer hold. Finally, the
String blocks a new activation of Rule 1.
- Removing salience 1 lets Rule2 fire before Rule1, so the latter does not have the time
to cancel the former
- Removing the setAction() causes Rule2 to re-activate "in place". Since the new
facts are equals, the engine does not try to replace the activation with a new one. So
lock-on-active does not apply (correctly)
- Removing the modify of course prevents any re-evaluation and tentative reactivation of
Rule2
- Removing lock-on-active prevents the blocking effect.
So, the engine behaves correctly. You should reconsider modifying an attribute when
it's a key, or find alternatives to lock-on-active such as property reactivity.
Please let me know if you need more explanations.
The ticket should be rejected.
Best
Davide
Rule do not fire when lock-on-active true present
-------------------------------------------------
Key: DROOLS-164
URL:
https://issues.jboss.org/browse/DROOLS-164
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 5.5.0.Final
Environment: Win7/64 Java6
Reporter: Sergey Alaev
Assignee: Mark Proctor
Given following rules:
1 rule "Rule1"
2 salience 1
3 when
4 $booking: TradeBooking()
5 $trade: TradeHeader() from $booking.getTrade()
6 not (String())
7 then
8 $trade.setAction("New");
9 modify($booking) {}
10 insert ("run");
11 end;
12
13 rule "Rule2"
14 lock-on-active true
15 when
16 $booking: TradeBooking( )
17 $trade: Object( ) from $booking.getTrade()
18 then
19
20 end
and instance of TradeBooking() object with booking.trade != null
i expect to get: Rule1 fired, Rule2 fired
but i get: Rule1 fired
I can get expected result if i comment out one of the following lines: 2, 8, 9, 14
I was unable to reproduce this issue using standard mutable class (java.util.Date), so
there are some details:
TradeBooking, TradeHeader are interfaces, instances are generated using JDK proxy.
$booking.getTrade() returns JDK Proxy over interface that inherits TradeHeader.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira