gpt4 book ai didi

java - 议程组在 Drools 中未按预期工作

转载 作者:行者123 更新时间:2023-12-02 11:27:23 24 4
gpt4 key购买 nike

现在,在我的 drools 项目中,我在单独的 DRL 文件中有两组规则,它们按议程组划分。对于议程组“preCheck”,我将该议程组中的每条规则的自动焦点设置为 true。示例:

rule "preCheckDuplicate"
agenda-group "preCheck"
auto-focus true
no-loop true
salience 50
when
$f : IngestFileMetadata(isDuplicate.equalsIgnoreCase("True"))
then
$f.setIsDuplicate("True");
end

对于其他议程组 - “defaultRules” - 规则没有设置自动焦点属性。示例:

rule "duplicate file default"
agenda-group "defaultRules"
activation-group "isDuplicate"
no-loop true
salience 0
when
$f : IngestFileMetadata(isDuplicate.equals("True"))
then
insert(createResponse($f));
end

通过其余 API 调用规则时,我还尝试通过 JSON 有效负载将焦点设置到“preCheck”议程组。示例:

{
"lookup": "defaultStatelessKieSession",
"set-focus": "preCheck",
"commands": [
{
"insert": {
"out-identifier": "IngestFileMetadata",
"return-object": "true",
"entry-point": "DEFAULT",
"object": {
"com.hms.ingestion.rules.IngestFileMetadata": {
* * * * * data attributes here * * * * *
}
}
}
},
{
"fire-all-rules": {"out-identifier": "fired"}
},
{
"query": {"name": "rulesResponses", "out-identifier": "rulesResponses"}
}
]
}

但是,当执行规则时,似乎首先评估“defaultRules”议程组中的规则。我不知道为什么。我对流口水还比较陌生,所以我完全有可能没有正确理解议程组的概念,但我确信这种设计将确保首先评估“预检查”规则。

任何人都可以提供任何关于为什么这种情况没有发生的见解吗?如果我需要提供更多详细信息,我可以。

提前致谢。

最佳答案

Agenda groups allow you to place rules into groups, and to place those groups onto a stack. The stack has push/pop behavior. Before going into how to use agenda group firstly, I want to say that configuring agenda group is depends on what type of KieSession you are using in your rule engine. For stateful Session, you can directly configure it by calling ksession.getAgenda().getAgendaGroup( "preCheck" ).setFocus();. For Stateless Session, you have to declare an explicit rule to set the focus of the session to the particular Agenda. You can use the below rule to set agenda in Stateless Session:

 rule "global"
salience 100
when
$f : IngestFileMetadata()
then
drools.setFocus($f.getAgenda());
end

Note : You have to find some way to get the agenda variable in your rule file. In the above example, getAgenda() is a method in your IngestFileMetadata class and it returns agenda value of String type

关于java - 议程组在 Drools 中未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49515918/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com