Drools Kie Server ignoring AgendaFilter

609 views Asked by At

I've two guided decision tables in one project. My requirement is to execute only those rules which belong to one decision table at any given point of time. I tried to use RuleNameEndsWithAgendaFilter("some suffix") with FireAllRulesCommand class but Kie server is not filtering the rules based on the passed AgendaFilter. It runs all the rules every time.

Drools Workbench version 7.2.0.Final and Drools Kie Server version 7.2.0.Final.

Below is the code snippet for the same:

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());
1

There are 1 answers

2
laune On

You cannot use the standard class RuleNameEndsWithAgendaFilter for filtering the rules of a decision table because rules from one table don't have equal endings.

Try RuleNameStartsWithAgendaFilter, possibly after renaming your tables.