Search in sources :

Example 1 with StatefulSessionPool

use of org.drools.kiesession.session.StatefulSessionPool in project drools by kiegroup.

the class KieContainerImpl method createKieSessionsPool.

StatefulSessionPool createKieSessionsPool(String kSessionName, KieSessionConfiguration conf, Environment env, int initialSize, boolean stateless) {
    KieSessionModel kSessionModel = kSessionName != null ? getKieSessionModel(kSessionName) : findKieSessionModel(false);
    if (kSessionModel == null) {
        log.error("Unknown KieSession name: " + kSessionName);
        return null;
    }
    InternalKnowledgeBase kBase = (InternalKnowledgeBase) getKieBaseFromKieSessionModel(kSessionModel);
    return kBase == null ? null : new StatefulSessionPool(kBase, initialSize, () -> {
        SessionConfiguration sessConf = conf != null ? (SessionConfiguration) conf : kBase.getSessionConfiguration();
        StatefulKnowledgeSessionImpl kSession = stateless ? ((StatefulKnowledgeSessionImpl) RuntimeComponentFactory.get().createStatefulSession(kBase, env, sessConf, false)).setStateless(true) : (StatefulKnowledgeSessionImpl) kBase.newKieSession(sessConf, env);
        registerNewKieSession(kSessionModel, kBase, kSession);
        return kSession;
    });
}
Also used : StatefulKnowledgeSessionImpl(org.drools.kiesession.session.StatefulKnowledgeSessionImpl) StatefulSessionPool(org.drools.kiesession.session.StatefulSessionPool) InternalKnowledgeBase(org.drools.kiesession.rulebase.InternalKnowledgeBase) KieSessionConfiguration(org.kie.api.runtime.KieSessionConfiguration) SessionConfiguration(org.drools.core.SessionConfiguration) KieSessionModel(org.kie.api.builder.model.KieSessionModel)

Aggregations

SessionConfiguration (org.drools.core.SessionConfiguration)1 InternalKnowledgeBase (org.drools.kiesession.rulebase.InternalKnowledgeBase)1 StatefulKnowledgeSessionImpl (org.drools.kiesession.session.StatefulKnowledgeSessionImpl)1 StatefulSessionPool (org.drools.kiesession.session.StatefulSessionPool)1 KieSessionModel (org.kie.api.builder.model.KieSessionModel)1 KieSessionConfiguration (org.kie.api.runtime.KieSessionConfiguration)1