我在一個項目中有兩個指導決策表。我的要求是隻執行那些在任何給定時間點屬於一個決策表的規則。我試圖在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());
除非您提供議程過濾器的代碼,否則如何判斷這是否正確?此外,您的規則表的頂部行,也許作爲一個CSV文本。 – laune
它是drools-core jar(版本:7.2.0.Final)的默認實現 –