Thank you. :)

And how do I catch the exceptions occurring while processing and executing the rules?


Hi,
If you are using 5.1 or greater, you can use a KnowledgeAgentEventListener to be notified when resource's compilation fails. You can create your own implementation of KnowledgeAgentEventListener, or you can use DefaultKnowledgeAgentEventListener and override just the methods you need:

kagent.addEventListener(new  DefaultKnowledgeAgentEventListener() {
   public void resourceCompilationFailed(ResourceCompilationFailedEvent event) {
       //ResourceCompilationFailedEvent contains a reference to kagent's kbuilder. You can use it to see what happened.
   }
});

Best,


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Sun, Oct 24, 2010 at 7:55 PM, Tina Vießmann <tviessmann@stud.hs-bremen.de> wrote:
What's the best way for checking for errors when using the following
code for creating a kbase?


        // ResourceChangeScanner
        ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
        sconf.setProperty("drools.resource.scanner.interval", "10");
        ResourceFactory.getResourceChangeScannerService().configure(sconf);

        ResourceFactory.getResourceChangeNotifierService().start();
        ResourceFactory.getResourceChangeScannerService().start();


        // knowledge base
        KnowledgeBaseConfiguration kbaseConf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kbaseConf.setOption(EventProcessingOption.STREAM);
        kbaseConf.setOption(MBeansOption.ENABLED);
        KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase(kbaseConf);


        // knowledge agent
        KnowledgeAgentConfiguration kagentConf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
        kagentConf.setProperty("drools.agent.newInstance", "false");
        KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("AITS CEP Engine Agent", kbase,
kagentConf);


kagent.applyChangeSet(ResourceFactory.newClassPathResource(myFile));


        // session
        fSession = kbase.newStatefulKnowledgeSession();


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

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