Rather than creating the knowledge base every time a request is made, you should be
creating a knowledge base once. Probably during application start-up. Each request should
just trigger creating a new session, which may well take just a few milliseconds.
Steve
On 5 Nov 2013, at 10:17, arpitmittal <arpitmittal2000(a)gmail.com> wrote:
Hi All,
My front end application has transaction timeout of 200 milli Sec and my
code is taking upto 1200 ms to load & compile the DRL & store in cache.
So I tried to create a package of compiled DRL so that it saves compilation
time at run time, but to my surprise the reponse time increated to 3000
milli sec.
Please let me know how to reduce the transaction time?
*I was using below method to use DRL:-*
ruleBase = RuleBaseFactory.newRuleBase(
String droolsPath = folder + "/" + <DRL file name>;
File f = new File(droolsPath);
FileInputStream fInputStream = new FileInputStream(f);
Reader source = new InputStreamReader(fInputStream);
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(source);
File processFile = new File(folder + "/" + < rules Flow File Name>);
FileInputStream processFileInputStream = new FileInputStream(processFile);
Reader processFileSource = new InputStreamReader(processFileInputStream);
builder.addProcessFromXml(processFileSource);
builder.compileAll();
Package[] pkg = builder.getPackages();
ruleBase.addPackages(pkg);
WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(customer);
workingMemory.startProcess(this.processName);
workingMemory.fireAllRules();
*I am using below code while using package:-*
Resource resourceRuleFlow = (Resource)
ResourceFactory.newFileResource(<rules Flow File path>);
Resource resourcePackage = (Resource)
ResourceFactory.newFileResource(<package File path>);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(resourceRuleFlow, ResourceType.DRF);
kbuilder.add(resourcePackage, ResourceType.PKG);
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.insert(customer);
ksession.startProcess(this.processName);
ksession.fireAllRules();
My understanding is if we are using package which contains compiled rules
then it should take less time as compared to DRL file.
Please help me how to sort out this issue..
--
View this message in context:
http://drools.46999.n3.nabble.com/How-to-reduce-transaction-time-tp402663...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users