I am trying to use KnowledgeAgent to auto update the knowledgebase when rules are updated at guvnor. Following is my Test Class that creates the kAgent and executes the rules every 3 Seconds.
/ import org.drools.KnowledgeBase; import org.drools.agent.KnowledgeAgent; import org.drools.agent.KnowledgeAgentConfiguration; import org.drools.agent.KnowledgeAgentFactory; import org.drools.io.ResourceFactory; import org.drools.runtime.StatefulKnowledgeSession; public class MainClass { public static void main(String[] st) throws Exception { KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration(); aconf.setProperty("drools.agent.newInstance", "true"); final KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("kagent", aconf); ResourceFactory.getResourceChangeNotifierService().start(); ResourceFactory.getResourceChangeScannerService().start(); kagent.applyChangeSet(ResourceFactory.newClassPathResource("ChangeSet.xml")); KnowledgeBase kbase = kagent.getKnowledgeBase(); while (true) { try { Thread.sleep(3000); kbase = kagent.getKnowledgeBase(); System.out.println("Number of packages(should be 1): " + kbase.getKnowledgePackages().size()); StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession(); session.insert(""); System.out.println("Number of rules fired: " + session.fireAllRules()); session.dispose(); } catch (Exception e) { e.printStackTrace(); } } } } / And following is my 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 http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd' > <add> <resource basicAuthentication="enabled" username="admin" password="admin" type="DRL" source="http://localhost:8080/brms/rest/packages/ReceiverConfigurationRules/source"></resource> </add> </change-set> / And I have one rules package "ReceiverConfigurationRules" and simple drl rule with no condition( so will always fire). So, when I run my program, for few times, it works as expected printing number of packages and number of rule fired as "1". However as soon as "DebugKnowledgeAgentEventListener" logs the following into the console, It starts printing number of packages with kBase as "0" and number of rules fired as "0". This is unexpected behavior. Is this a bug or am I missing something important? ==>[BeforeChangeSetAppliedEvent: org.drools.io.impl.ChangeSetImpl@34f2e383] ==>[BeforeChangeSetProcessedEvent: org.drools.io.impl.ChangeSetImpl@34f2e383] ==>[BeforeResourceProcessedEvent(RESOURCE_MODIFIED): [UrlResource path='http://localhost:8080/brms/rest/packages/ReceiverConfigurationRules/source']] ==>[AfterResourceProcessedEvent(RESOURCE_MODIFIED): [UrlResource path='http://localhost:8080/brms/rest/packages/ReceiverConfigurationRules/source']] ==>[AfterChangeSetProcessedEvent: org.drools.io.impl.ChangeSetImpl@34f2e383] ==>[KnowledgeBaseUpdatedEvent: org.drools.impl.KnowledgeBaseImpl@3fd7ada9] ==>[AfterChangeSetAppliedEvent: org.drools.io.impl.ChangeSetImpl@34f2e383] Weird thing is when I use local resource like source="file:\\\configRules.drl", everything is works perfect. Have anyone experienced such issue? I used drools 5.4.final core as well as 5.3 but same issue. I appreciate your help in advance. -- View this message in context: http://drools.46999.n3.nabble.com/Knowledge-Agent-unexpected-behavior-for-remote-resource-at-guvnor-tp4023893.html Sent from the Drools: User forum mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users