drl文件:
rule "pendingMsgSizeModified"
when
$tibcoEMSObj : TibcoEMSData(deliveredMsgCnt.contains("MB") && pendingMsgSize \> 100)
eval (!($tibcoEMSObj.typeOfAlert != null))
then
$tibcoEMSObj.setSendEmail(true);
$tibcoEMSObj.setTypeOfAlert($tibcoEMSobj.getTypeOfAlert()+"pendingMsgSize###");
update($tibcoEMSObj)
end它在此位置出现错误:$tibcoEMSobj.getTypeOfAlert()
Error : \[Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.$tibcoEMSobj()\]
\[Near : {... SObj.setTypeOfAlert($tibcoEMSobj.getTypeOfAlert()+ ....}\]我期望使用getter方法来获取它,并将字符串连接到另一个变量中并保存/更新它。
发布于 2022-04-01 21:12:31
你的语法到处都是。如果没有真正看到你的模型,你甚至很难知道你想要做什么。
但基于你所说的:
,我期望使用getter方法来获取它,并将字符串连接起来,以设置另一个变量并保存/更新它。
你提供的代码,我想这就是你想要做的:
rule "pendingMsgSizeModified"
when
$tibcoEMSObj : TibcoEMSData(
deliveredMsgCnt.contains("MB"),
pendingMsgSize > 100,
$alertType: typeOfAlert != null
)
then
String newAlert = $alertType + "pendingMsgSize###";
modify($tibcoEMSObj) {
setSendEmail(true)
setTypeOfAlert(newAlert)
}
end我认为您的eval要么是错误的,要么是完全错误的,因为它检查的值实际上是空的。除非您别无选择,否则不要使用eval。(我从来没有遇到过没有其他选择的情况。)
我还假定警报类型不会更改。我不知道您的sendEmail方法是做什么的,或者它是否有副作用;如果它确实有改变typeOfAlert的副作用,那么您当然需要在调用setSendEmail之后调用getTypeOfAlert()。
https://stackoverflow.com/questions/71712699
复制相似问题