以下是规则:
rule "RelStatusUpdateCalcCheck"
salience 55
no-loop true
when
$evt : UpdateRateStatusReq(statusID == RateStatusEnum.READY.getValue() || == RateStatusEnum.HOLIDAY_ROLL_FORWARD.getValue() || == RateStatusEnum.ROLL_FORWARD.getValue()) from entry-point RequestStream
$rr : ReliableRate(rateId == $evt.getRateID())
$dr : DerivedRate(holidayFlag == false, grfLock == false, $lr : listInputRateId, $lr.contains($evt.getRateID()))
then
cepService.relStatusUpdateCalcCheck($evt, $rr, $dr);
end**
最后一个条件表明,如果'holidayflag'为false且其他条件也满足,则只执行java方法。但即使holidayflag为true,该方法也会被执行。只有当我重新启动我的应用服务器时,当holidayflag为true时,该方法才会执行。为什么会这样?
答案 0 :(得分:2)
可能的解释是
您的工作记忆中有多个DerivedRate事实,这些事实与您的规则相符,原因是:
答案 1 :(得分:1)
Thanks for the reply. I got the root cause of this issue. Actually when I update the holidayFlag to 'true',the DerivedRate object is updated but the Drools session is never updated as the result of which when the rules gets executed it still refers to the old value. When I restart my app I load the Facts again that's why this issue gets resolved after restart.
Below is the code that i added in order to resolve this issue::
DerivedRate dr = (DerivedRate) qd.iterator().next().get("dr");
FactHandle fh = session.getFactHandle(dr); --> new code
dr.setHolidayFlag(true);
session.update(fh, dr); --> new code