[rules-users] Manage dynamically rules in KnowledgeBase

Mark Proctor mproctor at codehaus.org
Wed Jul 24 03:57:52 EDT 2013


https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/DynamicRulesTest.java


On 23 Jul 2013, at 17:26, tiahdomoina <rabarijaonadomoina at gmail.com> wrote:

> Hello :)
> 
> How can I manage dynamically rules in KnowledgeBase ? I mean remove, add or
> update rules without rebuilding a new KnowledgeBase or a new
> KnowledgeSession. Is it possible ?
> 
> I tried with a basic example:
> 
> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
> kbuilder.add(ResourceFactory.newClassPathResource("rule.DRL"),
> ResourceType.DRL);
> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
> kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
> StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
> // insertion of facts
> ksession.fireAllRules();		
> kbase.removeRule("package", "myRule");					
> ksession.fireAllRules();
> 
> But the rules don't seem to be fired the second time. I also tried to create
> a new session but the result is the same.
> 
> I don't wanna use a KnowledgeAgent because the modification of the rules is
> not very frequent.
> But when there is one, it has to be applied immediately and shouldn't wait
> for the interval of time of the scan.
> 
> If anyone has an idea :)
> 
> Thank you !
> 
> 
> 
> --
> View this message in context: http://drools.46999.n3.nabble.com/Manage-dynamically-rules-in-KnowledgeBase-tp4025108.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list