Re: [rules-users] Best way to have multiple kieBase dynamically
each time you wish to update, you need to increase the model’s version. You can do that with your existing kiebuilder and kiefilesystem. Then buildAll and make sure it’s added to KieRepository (if it’s not done automated, I forget if it is or isn’t). Once the new jar is in the KieRepository you can call kieContainer.updateToJar; and it will upgrade the changed kiebases. Mark On 23 Feb 2014, at 04:37, lukes mail2lok...@gmail.com wrote: Sorry for the confusion, what i actually meant was : lets say i started my application and with the sample code i wrote above, i created n kieBases and everything works fine, but now in the middle i want to create another kieBase and deploy a new drl file in that kieBase on the fly, and want to deploy on the same application or module which is running. Do i need to create a new jar now ? Or can i write in the same kieFileSystem and buildAll ? -- View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-have-multiple-kieBase-dynamically-tp4028247p4028252.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best way to have multiple kieBase dynamically
Thanks Mark, that's exactly i was thinking of. Because i don't have the permissions of deploying the jars on the fly. -- View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-have-multiple-kieBase-dynamically-tp4028247p4028259.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best way to have multiple kieBase dynamically
You need to specify the packages that the kiebase includes. That way different resources can be assigned to different kiebases KieBaseModel.addPackage(java.lang.String s); In the xml it’s a comma separated list packages=“ Mark On 22 Feb 2014, at 19:58, lukes mail2lok...@gmail.com wrote: Hi, What's the best way to have multiple kieBases dynamically on same/different KieFileSystem. let's say if i have 3 different drl(this can grow dynamically, so don't want to put in kconfig.xml)l files and i want all three of them to reside in different kiebases so that each session(stateful and stateless) created from the kiebase can have it's independent set of rules. Currently i a doing something like below: this.kFileSystem.write(com.sample + filename + .drl, content); this.kBuilder = this.kService.newKieBuilder(this.kFileSystem); this.kBuilder.buildAll(); // kieModule is automatically deployed to KieRepository if successfully built. if (this.kBuilder.getResults().hasMessages(Level.ERROR)) { throw new RuntimeException(Build Errors:\n + this.kBuilder.getResults().toString()); } this.kContainer = this.kService.newKieContainer(this.kRepository.getDefaultReleaseId()); But here, everything goes in to the same knowledgeBase. The actual problems i am trying to solve are below : 1) If i'll rebuild 1 kieBuilder and kieContainer, others won't get affected and users can work on them at the same time during runtime. 2) For the stateless sessions, there's no getAgendaGroup(name).setFocus(), so it won't have to execute all the rules in the universal kieBase in my case. Thanks in advance. -- View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-have-multiple-kieBase-dynamically-tp4028247.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best way to have multiple kieBase dynamically
Thanks Mark for the reply. you mean something like : KieServices kieServices = KieServices.Factory.get(); KieModuleModel kieModuleModel = kieServices.newKieModuleModel(); for( File ruleFile : ruleFiles) { KieBaseModel kieBaseModel1 = kieModuleModel.newKieBaseModel( KBase1 ) .setDefault( true ) .setEqualsBehavior( EqualityBehaviorOption.EQUALITY ) .setEventProcessingMode( EventProcessingOption.STREAM ); KieBaseModel1.addPackage(java.lang.String s); ... } kfs.writeKModuleXML(kieModuleModel .toXML()); this.kieBuilder = ks.newKieBuilder(kfs).buildAll(); this.kContainer = this.kService.newKieContainer(this.kRepository.getDefaultReleaseId()); biut wouldn't that create another jar ? And if some new ruleFile come, then do i have to create all the kieBases again or can i just create the new kieBase? And if i need to modify any of the drl file, then will it rebuild the whole kieBuilder ? -- View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-have-multiple-kieBase-dynamically-tp4028247p4028249.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best way to have multiple kieBase dynamically
take a look at this kmodule.xml. This is one maven project,and thus one jar, but with 1..n named kiebases in it. Each kiebase selects resources from different folders. https://github.com/droolsjbpm/drools/blob/master/drools-examples/src/main/resources/META-INF/kmodule.xml The model you are working with just creates the kmodule.xml that ends up in the jar. Mark On 23 Feb 2014, at 00:26, lukes mail2lok...@gmail.com wrote: Thanks Mark for the reply. you mean something like : KieServices kieServices = KieServices.Factory.get(); KieModuleModel kieModuleModel = kieServices.newKieModuleModel(); for( File ruleFile : ruleFiles) { KieBaseModel kieBaseModel1 = kieModuleModel.newKieBaseModel( KBase1 ) .setDefault( true ) .setEqualsBehavior( EqualityBehaviorOption.EQUALITY ) .setEventProcessingMode( EventProcessingOption.STREAM ); KieBaseModel1.addPackage(java.lang.String s); ... } kfs.writeKModuleXML(kieModuleModel .toXML()); this.kieBuilder = ks.newKieBuilder(kfs).buildAll(); this.kContainer = this.kService.newKieContainer(this.kRepository.getDefaultReleaseId()); biut wouldn't that create another jar ? And if some new ruleFile come, then do i have to create all the kieBases again or can i just create the new kieBase? And if i need to modify any of the drl file, then will it rebuild the whole kieBuilder ? -- View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-have-multiple-kieBase-dynamically-tp4028247p4028249.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best way to have multiple kieBase dynamically
Sorry for the confusion, what i actually meant was : lets say i started my application and with the sample code i wrote above, i created n kieBases and everything works fine, but now in the middle i want to create another kieBase and deploy a new drl file in that kieBase on the fly, and want to deploy on the same application or module which is running. Do i need to create a new jar now ? Or can i write in the same kieFileSystem and buildAll ? -- View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-have-multiple-kieBase-dynamically-tp4028247p4028252.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users