从客户端获取在决策服务器上执行的触发规则名称(Redhat Decision Manager)

Get triggered rule names which is executing on decision server from client side (Redhat Decision Manager)

我正在使用 REST api 使用无状态 kie 会话在决策服务器 (Redhat Decision Manager 7.2) 上执行规则。我目前正在获取触发规则的数量,但我还想获取这些规则的名称。这可能吗?

KieServicesConfiguration conf = KieServicesFactory.newRestConfiguration(URL, USER, PASSWORD);

List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>();

commands.add((GenericCommand<?>)
KieServices.Factory.get().getCommands().newInsert(applicant, "applicant"));

commands.add((GenericCommand<?>)
KieServices.Factory.get().getCommands().newInsert(loan, "loan"));

commands.add((GenericCommand<?>)KieServices.Factory.get().getCommands().newFireAllRules("numberOfFiredRules"));

KieCommands kieCommands = KieServices.Factory.get().getCommands();

BatchExecutionCommand batchCommand = kieCommands.newBatchExecution(commands, "default-stateless-ksession");

ServiceResponse<ExecutionResults> executeResponse = ruleServicesClient
                .executeCommandsWithResults("loan-application_1.2.0", batchCommand);

System.out.println("Number of fired rules:" executeResponse.getResult().getValue("numberOfFiredRules"));

您必须使用 AgendaEventListener 来跟踪已执行的规则。通过实施 org.kie.api.event.rule.AgendaEventListener 界面,您可以捕获这些细节。

为了知道触发了哪些规则,我添加了一个带有自定义代码(Action BRL 片段)的操作列,该列在我的事实字段之一中写入规则名称。您可以从 rule.name 获取它。 示例:myFact.logMyRuleName(rule.name)