use of org.kie.api.builder.model.KieSessionModel.KieSessionType in project kiegroup-examples by tkobayas.
the class MyKieServerWarmupEventListener method internalWarmupFireOnly.
private void internalWarmupFireOnly(KieContainerInstance containerInstance) {
LOGGER.info(" internalWarmupFireOnly");
KieContainer kieContainer = containerInstance.getKieContainer();
Collection<String> kieBaseNames = kieContainer.getKieBaseNames();
// warmup all kieSessions
kieBaseNames.stream().flatMap(kieBaseName -> kieContainer.getKieSessionNamesInKieBase(kieBaseName).stream()).forEach(kieSessionName -> {
LOGGER.info("warmup : kieSessionName = {}", kieSessionName);
KieSessionType type = kieContainer.getKieSessionModel(kieSessionName).getType();
if (type == KieSessionType.STATEFUL) {
KieSession kieSession = kieContainer.newKieSession(kieSessionName);
kieSession.fireAllRules();
kieSession.dispose();
} else {
StatelessKieSession statelessKieSession = kieContainer.newStatelessKieSession(kieSessionName);
final List<Command> cmds = new ArrayList<Command>();
cmds.add(CommandFactory.newFireAllRules());
BatchExecutionCommand batchExecutionCommand = CommandFactory.newBatchExecution(cmds);
final ExecutionResults batchResult = (ExecutionResults) statelessKieSession.execute(batchExecutionCommand);
}
});
}
Aggregations