Drools 仅触发那些在 Spring Boot 文件中进行配置的规则。

huangapple go评论77阅读模式
英文:

Drools fire only those rules which names are configured in a file Spring boot

问题

我有一个 Yml(我对任何扩展名都可以接受)文件,我在其中存储所有规则的名称。我需要触发在此文件中配置的所有名称。当我想要禁用执行规则时,我只需将该规则名称注释掉或从该文件中删除,以便该规则不会被执行。

英文:

I had a Yml(I am okay with any extension ) file where I am storing all the rules' names. I need to fire all the names that are configured in this file. When I want to Disable a rule for execution I will just comment or I will remove that rule name in that file so that the rule will not be executed.

答案1

得分: 2

介绍具有 Set<String> 规则的 EligibleRules,并为每个规则添加额外条件。

规则 "规则1"
    EligibleRules(rules 包含 "规则1")
    ...

在会话中插入一个 EligibleRules 的单个副本,在可选规则列表更改之前更新规则集,然后在调用 fireAllRules() 之前更新 Drools 的事实句柄,以便通知变更。

英文:

Introduce EligibleRules with Set&lt;String&gt; rules and make additional condition for each rule.

rule &quot;Rule 1&quot;
when
	EligibleRules(rules contains &quot;Rule 1&quot;)
    ...

insert single copy of EligibleRules into the session, update set of rules before fireAllRules() when the list of eligible rules changes and update fact handle for drools to notice the change.

huangapple
  • 本文由 发表于 2020年6月29日 17:49:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/62635476.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定