规则失败后从规则文件返回

returning from rule file after rule fails

我在 drool 文件中有 3 个规则。

规则 1

规则 2

规则 3

如果规则 1 的条件为真,则不应执行规则 2 或 3。如果条件失败,则应转到下一条规则,直到条件为真的规则。

如何操作?

我认为 "activation-group" 属性可以解决您的问题。根据 drools documentation 的说法如下

Rules that belong to the same activation-group, identified by this attribute’s string value, will only fire exclusively. More precisely, the first rule in an activation-group to fire will cancel all pending activations of all rules in the group, i.e., stop them from firing.

如果您希望您的规则按顺序执行,您也可以尝试为它们赋予 salience 属性。