简体   繁体   中英

Drools: can we add/amends rules at runtime

can we add/amends rules (.drl or decision table) at runtime in drools?

For example I created a simple decision table rule, this rule worked fined, however any change in decision table was not reflected in rule evaluation at runtime until the jvm was restarted.

Tried this re-creating the KieSession

was able to do this by creating new KieSession instance as below:

This was done with drools version: 8.32.0 java 11

KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(); builder.add(ResourceFactory.newFileResource(), ResourceType.DTABLE); InternalKnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); knowledgeBase.addPackages(builder.getKnowledgePackages()); knowledgeBase.newKieSession(); =====================

the new session was created whenever there was any amend made in the rule

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM