[rules-users] KnowledgeAgent Changeset problems

albertorugnone arugnonechemical at gmail.com
Wed Apr 4 10:12:47 EDT 2012


Thank you every body for your answer, unfortunately I was't able to reply to
you until now because other stuff overwhelmed me literally at work.
Anyway I was going ahead using KnowledgeAgent, following your comments and
other suggestion. Now I am able to load rules applying change set with
KnowledgeAgent (thank you!!!), but honestly this is a poor success because,
even if when I change the rule KnowledgeAgent says "incremental build of
KnowledgeBase finished and in use" nothing changes. 
It seems that changes at rules have no effect and it is pretty weird. I made
a maven project with eclipse to explain you better my problem. Is a simple
main. I am working for a better junit test. Anyway if you change the rule in
the folder knowledge you can test the problem by yourself.
Briefly I will explain the project:

Here the code:

		_l.warn("START");
		String xml = "";
		xml += "<change-set xmlns='http://drools.org/drools-5.0/change-set'&quot;;
		xml += &quot;   
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'&quot;;
		xml += &quot;   
xs:schemaLocation='http://drools.org/drools-5.0/change-set
drools-change-set-5.0.xsd' >";
		xml += "    <add> ";
		xml += "        <resource source='Z:/EXP/drools-test/knowledge/test.drl'
type='DRL' />";
		xml += "    </add> ";
		xml += "</change-set>";
		FileManager fileManager = new FileManager();
		File fxml = fileManager.newFile("changeset.xml");
		Writer output = new BufferedWriter(new FileWriter(fxml));
		output.write(xml);
		output.close();
		// build a KnowledgeAgent
		ResourceFactory.getResourceChangeNotifierService()
						.start();
		ResourceFactory.getResourceChangeScannerService()
						.start();

		final ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService()
																		.newResourceChangeScannerConfiguration();
		sconf.setProperty("drools.resource.scanner.interval", "2");
		ResourceFactory.getResourceChangeScannerService()
						.configure(sconf);

		final KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
		aconf.setProperty("drools.agent.scanDirectories", "true");
		aconf.setProperty("drools.agent.scanResources", "true");
		/*
		 * important newInstance has to be false in order to update the
		 * knowledge base and not rebuild a new one
		 */
		aconf.setProperty("drools.agent.newInstance", "false");
		final KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent("pch.sel.knowledge.agent", aconf);
		// if (_l.isDebugEnabled()) {
		/* we need some log every time */
		agent.setSystemEventListener(new PrintStreamSystemEventListener());
	
agent.applyChangeSet(ResourceFactory.newClassPathResource("pch.sel.kwset.xml"));
		// fire rules
		StatefulKnowledgeSession session =
agent.getKnowledgeBase().newStatefulKnowledgeSession();
		session.fireAllRules();
		_l.warn("END");


and here the rule


package it.ipiu.drools.KnowledgeAgent.test

rule "test rule" timer(int: 0s 2s)
    when
        eval(true);
    then
	    System.out.println("ciao");
end



If I try to change timer from 2s to 2m nothing changes even if
KnowledgeAgent seems to reload all. 

*Please help!!! I googled the problem everywhere without solution!!!*



--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeAgent-Changeset-problems-tp3787165p3884201.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list