I would have thought you could re-use the same session in a given single Thread - Session is not Thread-Safe but not unsafe to reuse.<div><br></div><div>As an aside, I wonder whether you can use a single session across all Threads if you used different Entry Points for each Thread (although you'd probably have to duplicate rules for each Entry Point so not sure the pros- out weigh the cons-). Edson, Mark?<br>
<br><div class="gmail_quote">2010/9/27 Nadav Hashimshony <span dir="ltr"><<a href="mailto:nadavh@gmail.com">nadavh@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">My rule engine server is multi threaded.<br><br>in the server main i build a knowledgebase:<br><br>KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(droolsConf, null);<br>
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);<br>builder.add(ResourceFactory.newFileResource("path to drools pkg", ResourceType.PKG);<br> <br> KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();<br>
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());<br><br>i have 10 threads that have the following code:<br><br><br><br>thread run method:<br><br><br>as long as a Vector has data do:<br><br>1. StatelessKnowledgeSession droolsSession= m_droolsKagent.getKnowledgeBase().newStatelessKnowledgeSession();<br>
2. get data object from a vector<br>3. create fact model from data<br>4. droolsSession.insert(facts);<br>5. droolsSession.fireAllRules();<br>6. do stuff with the response<br>7.droosSession.dispose<br>8.get next object from vector.<br>
<br><br>Questions:<br>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?<br><br>Thanks<br>Nadav.<br></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>