Drools Rule format for firing only once

Deadly 提交于 2019-12-06 07:28:07

Keep the rules as simple as possible. While it is feasible to check for the presence of the inserted AccoundIsGood(), it is recommended to write the logic so that only the existence of a single good subsection is tested. Also, you need a from to extract the subsections from the Account object.

rule testForGood
when
  $account: Account( $sub: subsections )
  exists SubSection( status == "GOOD" ) from $sub
then
  insertLogical( new AccountIsGood($account) );
end

It might be a good idea to keep insertLogical, if there is a chance that the subsection status might change away from "GOOD": the logically inserted fact would be retracted if the accound doesn't have at lease one GOOD section.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!