[rules-users] Question to Knowledge-Agent Behaviour

Peach Wyss peach_wyss at yahoo.com
Thu Mar 13 07:47:19 EDT 2014


Hy all

We're having the following situation in our application:

ChangeSet:
<change-set xmlns='http://drools.org/drools-5.0/change-set' xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
  xs:schemaLocation='http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd'>
  <add>
    <resource source='file:rules/rules.pkg' type='PKG' />
  </add>
</change-set>


Code:
...
// Build initial KnowledgeBase
KnowledgeBuilderConfiguration kbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null, classloaders);
knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbuilderConfig);
knowledgeBuilder.add(resource, resourceType); //Resource: URL-Resource (Patch to ChangeSet), ResourceType: ChangeSet
Collection<KnowledgePackage> knowledgePackages = knowledgeBuilder.getKnowledgePackages();
knowledgeBase.addKnowledgePackages(knowledgePackages);

// Create and configure Knowledge Agent
KnowledgeAgentConfiguration knowledgeAgentConfig = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
knowledgeAgentConfig.setProperty("drools.agent.useKBaseClassLoaderForCompiling", "true");
knowledgeAgentConfig.setProperty("drools.agent.newInstance", "false");
knowledgeAgent = KnowledgeAgentFactory.newKnowledgeAgent("MyAgent", knowledgeBase, knowledgeAgentConfig);
knowledgeAgent.addEventListener(new KnowledgeAgentEventListener() {...} // Just for debugging purposes
knowledgeAgent.monitorResourceChangeEvents(true);
knowledgeAgent.applyChangeSet(resource);

// Configure Notification and Scanner
ResourceChangeScannerConfiguration resourceChangeScannerConfig = ResourceFactory
          .getResourceChangeScannerService().newResourceChangeScannerConfiguration();
resourceChangeScannerConfig.setProperty("drools.resource.scanner.interval", "10");
ResourceFactory.getResourceChangeScannerService().configure(resourceChangeScannerConfig);
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();

// Get KnowledgeBase from Agent
knowledgeBase = knowledgeAgent.getKnowledgeBase();
...


When i replace the rules.pkg with a new package (exported from guvnor with a newer "Date Modified"), the Knowledge-Base is newly generated. When I replace the pkg with the Package from the previous Version (older "Date modified"), nothing happens (despite the pkg has changed).

Question:
Does the agent only updates the Knowledge-Base, when the replaced pkg-File has a newer "Date Modified"?
In our scenario, the expected behaviour would be that the Agent updates the Knowledge-Base everytime the pkg-file changes, so that we can switch between newer and older versions of the pkg-file. Any idea how to achieve this?

Thanks for your help.

Kind regards,
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140313/2fd6f01f/attachment.html 


More information about the rules-users mailing list