Something like this is working for me -
private StatefulKnowledgeSession getSession() {
LogUtil.decisionLogger.info("Getting session for Rules Engine ...");
// Set the interval on the ResourceChangeScannerService if you are
to use it
// and default of 60s is not desirable.
final ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
// set the disk scanning interval to 30s, default is 60s
sconf.setProperty("drools.resource.scanner.interval", "30");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
knowledgeBaseFromDecisionTable =
KnowledgeBaseFactory.newKnowledgeBase();
final KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
// we want to scan directories, not just files, turning this on
turns on file
// scanning
aconf.setProperty("drools.agent.scanDirectories", "true");
// resource changes results in a new instance of the KnowledgeBase
being
// built, this cannot currently be set to false for incremental
building
aconf.setProperty("drools.agent.newInstance", "true");
final KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("kagent",
knowledgeBaseFromDecisionTable, aconf);
kagent.applyChangeSet(ResourceFactory.newClassPathResource("ChangeSet.xml"));
//kagent.applyChangeSet(ResourceFactory.newFileResource("c:/changeset.xml"));
return kagent.getKnowledgeBase().newStatefulKnowledgeSession();
}
-------------
ChangeSet.xml
<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
drools-change-set-5.0.xsd' >
<add>
<resource
source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/MyGeneralRecommendations/MyDevelopment.drl'
type='DRL' />
</add>
</change-set>
------------------------------------------------------------------------------------------------------
--
View this message in context:
http://n3.nabble.com/Integrating-rules-with-your-applications-Changeset-x...
Sent from the Drools - User mailing list archive at
Nabble.com.