Drools Kie服务器忽略AgendaFilter
我在一个项目中有两个指导决策表。我的要求是只执行那些在任何给定时间点属于一个决策表的规则。我试图在FireAllRulesCommand类中使用RuleNameEndsWithAgendaFilter(“some suffix”),但Kie服务器没有根据传递的AgendaFilter过滤规则。它每次都运行所有规则。Drools Kie服务器忽略AgendaFilter
Drools工作台版本7.2.0.Final和Drools Kie服务器版本7.2.0.Final。
下面是相同的代码片段:
KieServicesConfiguration configuration = KieServicesFactory.newRestConfiguration(serverUrl, user, password);
Set<Class<?>> allClasses = new HashSet<Class<?>>();
allClasses.add(OrderItem.class);
configuration.addExtraClasses(allClasses);
configuration.setMarshallingFormat(MarshallingFormat.JAXB);
OrderItem oi = new OrderItem("Mobile", 7000.00, 0.00, "");
KieServicesClient client = KieServicesFactory.newKieServicesClient(configuration);
// work with rules
List<ExecutableCommand<?>> commands = new ArrayList<ExecutableCommand<?>>();
BatchExecutionCommandImpl executionCommand = new BatchExecutionCommandImpl(commands, "defaultKieSession");
InsertObjectCommand insertObjectCommand = new InsertObjectCommand();
insertObjectCommand.setOutIdentifier("orderItem");
insertObjectCommand.setObject(oi);
FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
fireAllRulesCommand.setAgendaFilter(new RuleNameEndsWithAgendaFilter("MyRuleSuffix", true));
commands.add(insertObjectCommand);
commands.add(fireAllRulesCommand);
RuleServicesClient ruleClient = client.getServicesClient(RuleServicesClient.class);
ServiceResponse<String> response = ruleClient.executeCommands(containerId, executionCommand);
System.out.println(response.getResult());
您不能使用标准类RuleNameEndsWithAgendaFilter
用于过滤决策表的规则,因为从一个表中的规则不具有相同的结局。
尝试RuleNameStartsWithAgendaFilter
,可能在重命名表后。
在我的情况下,RuleNameEndsWithAgendaFilter应该像我的规则名称一样工作,“Row 1 MyProject”,“Row 2 MyProject”,“Row 3 MyProject“..”Row n MyProject“。因此,RuleNameEndsWithAgendaFilter(“MyProject”)应该可以工作。 –
那么,如果你更清楚一切,为什么你会问问题? - 您是否尝试在“RuleNameEndsWithAgendaFilter”的修改版本中打印实际规则名称? - 不知道该规则表的文本是什么样子的,以及规则名称是如何生成的。 – laune
除非您提供议程过滤器的代码,否则如何判断这是否正确?此外,您的规则表的顶部行,也许作为一个CSV文本。 – laune
它是drools-core jar(版本:7.2.0.Final)的默认实现 –