[rules-users] Multi threaded rule engine question.

Greg Barton greg_barton at yahoo.com
Mon Sep 27 18:57:21 EDT 2010


I wouldn't reuse a stateless session.  You could reuse a stateful session and clean up between runs, but session creation is not that expensive. (and easily less expensive than cleanup of a stateful session, mattering on the complexity of your rules)

GreG

On Sep 27, 2010, at 8:39, Nadav Hashimshony <nadavh at gmail.com> wrote:

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.
_______________________________________________
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