0
votes

I develop web application using Drools. All my drools files store into the database. After modifying some rule I must create new KnowledgeBase and add packages which I create from rules. How I can update only those packages in KnowledgeBase that I need, because regenerate all KnowledgeBase very expensive of time; For example I make next step;

User edit rule and push apply button. After that I do something that:

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add( ResourceFactory.newReaderResource( Reader, getClass() ),ResourceType.DRL ); KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

I store rule script how text in database and use Reader to add package in KnowledgeBuilder.. I take rule database format from here http://docs.codehaus.org/display/DROOLS/Loading+and+managing+rules+dynamically+from+a+database

I tried to remove package by name from Knowledge Base and add again but not successful. What I must to do for update my Knowledge Base. I can't create new Knowledge Base every time when user edit and save rule, I must do something actions for update some part of Knowledge Base, let me put it this way.

Please, help.

2

2 Answers

0
votes

Did you read about the knowledgeAgent inside the drools documentation? That component contains the logic to merge new changes into an existing knowledge base, as far as I remember. Cheers

0
votes

I read what knowledgeAgent work only with changeset.xml configuration and scan resurce which was define in changeset.xml