How to load Drools Rule From DB -


i trying load drool rule file database. how can fire rule?

kbuilder.add(     resourcefactory.newclasspathresource("myrule.drl"),     resourcetype.drl ); 

provide content of rule db (jdbc etc.) , store in variable. (before kie drools) in kbuilder.

string rulecontent; // fill db in diffrent method/aspect  knowledgebase kbase = knowledgebasefactory.newknowledgebase(); knowledgebuilder kbuilder = knowledgebuilderfactory.newknowledgebuilder(); resource r = resourcefactory.newreaderresource((reader) new stringreader(rulecontent)); kbuilder.add(dsl, resourcetype.drl); if (kbuilder.haserrors()) {     log.error(kbuilder.geterrors().tostring()); } kbase.addknowledgepackages(kbuilder.getknowledgepackages()); statefulknowledgesession ksession = kbase.newstatefulknowledgesession();  // prepare fact object  ksession.insert(factobject); ksession().fireallrules() 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -