[rules-users] Multi threaded rule engine question.

Nadav Hashimshony nadavh at gmail.com
Mon Sep 27 09:39:32 EDT 2010


My rule engine server is multi threaded.

in the server main i build a knowledgebase:

KnowledgeBuilderConfiguration config =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(droolsConf, null);
KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);
builder.add(ResourceFactory.newFileResource("path to drools pkg",
ResourceType.PKG);

KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());

i have 10 threads that have the following code:



thread run method:


as long as a Vector has data do:

1. StatelessKnowledgeSession droolsSession=
m_droolsKagent.getKnowledgeBase().newStatelessKnowledgeSession();
2. get data object  from a vector
3. create fact model from data
4. droolsSession.insert(facts);
5. droolsSession.fireAllRules();
6. do stuff with the response
7.droosSession.dispose
8.get  next object from vector.


Questions:
1. should i create each time the droolsSession? or can i resuse the same
one, meaning can i create it in the Thread's constractor?

Thanks
Nadav.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100927/ac6d5e72/attachment.html 


More information about the rules-users mailing list