[rules-users] Multiple threads for KieBuilder
RichardAmbridge
richard.ambridge at gmail.com
Thu May 8 05:04:46 EDT 2014
Hi,
We have over 20000 rules in our drools implementation. In drools 5 we
could build multiple packages in different threads and then create a
Knowledge base joining all those packages together.
e.g.
Thread:
knowledgeB = KnowledgeBuilderFactory.newKnowledgeBuilder();
knowledgeB.add(ResourceFactory.newReaderResource(new
StringReader(sb.toString())), ResourceType.DRL);
Then in the main compiler, once all threads have finished
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase(conf);
for each thread:
knowledgeBase.addKnowledgePackages(thrds[t].getKnowledgeB().getKnowledgePackages());
I can't seem to find anyway to do that with the new KIE implementation.
What I would like to do is something like:
Thread:
Create sb to have lots of rules
KieServices kieServices = KieServices.Factory.get();
KieFileSystem kfs = kieServices.newKieFileSystem();
kfs.write("src/main/resources/rules.drl", sb.toString());
KieBuilder kieBuilder = kieServices.newKieBuilder(kfs);
kieBuilder.buildAll();
..check errors
KieContainer kieContainer =
kieServices.newKieContainer(kieBuilder.getKieModule().getReleaseId());
KieBase kieBase = kieContainer.newKieBase(kieBaseConfiguration);
In main compiling, create multiple threads, each with its own rule set.
Then when all threads completed, take all the kieBase objects and merge into
one base.
then KieSession ksession=mergedKieBase.newKieSession();
We compile our rules offline and then load into our running servers. The
compile server is a multicore server, but buildAll is single threaded.
Is this possible?
Many thanks for the support,
Ric
--
View this message in context: http://drools.46999.n3.nabble.com/Multiple-threads-for-KieBuilder-tp4029481.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list