0

我在一个项目中有两个引导式决策表。我的要求是在任何给定时间点只执行属于一个决策表的那些规则。我尝试将 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());
4

1 回答 1

0

您不能使用标准类RuleNameEndsWithAgendaFilter来过滤决策表的规则,因为来自一个表的规则没有相同的结尾。

尝试RuleNameStartsWithAgendaFilter,可能在重命名表之后。

于 2017-10-10T18:07:37.793 回答