I have a domain specific application which has a drools version 7 libray as dependency so all the rules are loaded in application memory. I am looking to move to Kogito but having following doubts
- In drools i inject rules as drls in
KnowledgeBuilder
programmatically. My rules are very dynamic and keeps on changing so I update the kiesession using a scheduler. In the kogito-examples there is aKieRuntimeBuilder
which automatically picks the drls from resource folder.
if ( ruleString != null ) {
ruleSet = ResourceFactory.newReaderResource( new StringReader( ruleString ) );
} else {
ruleSet = ResourceFactory.newFileResource( ruleFilePath );
}
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ruleSet, ResourceType.DRL );
if ( kbuilder.hasErrors() ) {
System.out.println( kbuilder.getErrors().toString() );
throw new RuntimeException( BaseMessages.getString( PKG, "RulesData Error" ) );
}
Ques: How to add drl in runtime in KieRuntimeBuilder ?
Ques : How to update the session periodically ?