我在一个项目中有两个引导决策表。我的要求是在任何给定时间点仅执行属于一个决策表的规则。我尝试将RuleNameEndsWithAgendaFilter("一些后缀")与FireAllRulesCommand类一起使用,但Kie服务器没有根据传递的AgendaFilter过滤规则。它每次都运行所有规则。
DroolsWorkbench 版本 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());
不能使用标准类RuleNameEndsWithAgendaFilter
来筛选决策表的规则,因为一个表中的规则没有相等的结尾。
尝试RuleNameStartsWithAgendaFilter
,可能是在重命名表之后。