in kogito-java-examples/rules-embedded-mode-example/src/main/java/org/kie/kogito/rules/embedded/RulesEmbeddedModeExample.java [21:56]
public static void main(String[] args) {
KieServices kieServices = KieServices.Factory.get();
KieContainer kieContainer = kieServices.getKieClasspathContainer();
logger.info("-----> Now we execute rules in the stateful session <-----");
KieSession kieSession = kieContainer.newKieSession();
kieSession.addEventListener(new DebugRuleRuntimeEventListener());
ExecutionResults executionResults = kieSession.execute(
CommandFactory.newBatchExecution(Arrays.asList(
CommandFactory.newInsert(new Applicant("#0001", 20), "applicant"),
CommandFactory.newInsert(new LoanApplication("#0001"), "application"),
new SetActiveAgendaGroup("applicationGroup"),
CommandFactory.newFireAllRules()
))
);
logger.info("application: " + executionResults.getResults().get("application"));
kieSession.dispose();
logger.info("-----> Now we execute rules in the stateless session <-----");
StatelessKieSession statelessKieSession = kieContainer.newStatelessKieSession();
statelessKieSession.addEventListener(new DebugRuleRuntimeEventListener());
ExecutionResults statelessExecutionResults = statelessKieSession.execute(
CommandFactory.newBatchExecution(Arrays.asList(
CommandFactory.newInsert(new Applicant("#0001", 20), "applicant"),
CommandFactory.newInsert(new LoanApplication("#0001"), "application"),
new SetActiveAgendaGroup("applicationGroup") ))
);
logger.info("application: " + statelessExecutionResults.getResults().get("application"));
}