[rules-users] Multiple threads for KieBuilder

Mark Proctor mproctor at codehaus.org
Fri May 9 18:14:50 EDT 2014


This is not possible in the public api now, but it seems like this approach would be a valid thing to add to the internal core of Drools. So that we do parallel compilation, seamlessly, for all our users. I’m not sure when we’ll have time to do it, although maybe someone from the community can work with us to do this?

Mark
On 8 May 2014, at 10:04, RichardAmbridge <richard.ambridge at gmail.com> wrote:

> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list