Hi...
I'm trying to use KnowledgeAgent in my application; I already saw he
examples in the docs..but somehow I'm still not sure whether I've used it
correctly. 
The case is that I implement a STATELESS session bean, which provides the
method that makes use of rule engine.

private KnowledgeBase kbase;

private KnowledgeAgentConfiguration aconf;

private KnowledgeAgent kagent;

public myBeansMethod(...) {
......

   if (this.kbase == null) {
        this.kbase = KnowledgeBaseFactory.newKnowledgeBase();
   }

   if (this.aconf == null) {
      LOG.info("Creating new KnowledgeAgentConfigurator ...");
      this.aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
      this.aconf.setProperty("drools.agent.scanDirectories", "true");
      this.aconf.setProperty("drools.agent.newInstance", "true");
   }

   if (this.kagent == null) {
     this.kagent =  KnowledgeAgentFactory.newKnowledgeAgent("kagent",
this.kbase,  this.aconf);
    }

   
this.kagent.applyChangeSet(ResourceFactory.newFileResource(this.CHANGE_SET));
    StatelessKnowledgeSession ksession =                                        
                                                                 
kagent.getKnowledgeBase().newStatelessKnowledgeSession();
    .........

}

My purpose is to create as few new instances as possible on calling the
method, but still get the latest version of the rules. Is this already
correct?

Is there any way to avoid rebuilding/updating the knowledge base if it is
still the very same resource the change set refering to? (not updated one)

Thanks in advance
-- 
View this message in context: 
http://www.nabble.com/%22less-time--and-memory-consuming%22-usage-of-KnowledgeAgent---need-some-advice-tp21501437p21501437.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to