我在一个项目中有两个引导式决策表。我的要求是在任何给定时间点只执行属于一个决策表的那些规则。我尝试将 RuleNameEndsWithAgendaFilter("some suffix") 与 FireAllRulesCommand 类一起使用,但 Kie 服务器没有根据传递的 AgendaFilter 过滤规则。它每次都运行所有规则。
Drools Workbench 版本 7.2.0.Final 和 Drools Kie Server 版本 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());