[rules-users] Multi threaded rule engine question.

Michael Anstis michael.anstis at gmail.com
Tue Sep 28 03:23:42 EDT 2010


True, thanks Greg.

On 27 September 2010 23:57, Greg Barton <greg_barton at yahoo.com> wrote:

> 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
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100928/8d04e3d7/attachment.html 


More information about the rules-users mailing list