1

下面是规则:


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 为真时,该方法也会被执行。只有当我重新启动我的应用程序服务器时,当holidayflag 为真时,该方法才会被执行。为什么会这样?

4

2 回答 2

2

一个可能的解释是

您的工作记忆中有多个 DerivedRate 事实,这些事实与您的规则相匹配,因为:

  • 由于编程错误(例如,从多个线程访问知识库的静态实例),您插入了这些事实
  • 您使用有状态的知识会话,而 DerivedRate 事实是先前操作的剩余物。
于 2012-12-14T17:56:45.660 回答
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
于 2012-12-17T04:02:57.767 回答