从KieBase删除规则后,我尝试重新创建KieSession,但删除的规则仍在触发。
我创建了一个KieBase并使用以下代码删除了一条规则:
KieServices service = KieServices.Factory.get();
KieFileSystem fileSystem = service.newKieFileSystem();
KieBuilder builder = service.newKieBuilder(fileSystem);
ReleaseId releaseId1 = service.getRepository().getDefaultReleaseId();
KieContainer kContainer = service.newKieContainer(releaseId1);
KieSession ksession = kContainer.newKieSession(sessionConfig);
KieBaseConfiguration config = service.newKieBaseConfiguration();
KieBase base = kContainer.newKieBase(config);
base.removeRule("com.somepackage", "rule1");
KieSession ksession1 = kContainer.newKieSession(sessionConfig);
但是,当我根据ksession1评估事实时,rule1仍在触发。如何将已编辑的KieBase重新加载到新会话中?
最佳答案
您可以从修改后的KieBase创建会话:
KieSession ksession1 = base.newKieSession();