[rules-users] Can drools work in multithreaded environment?

Edson Tirelli tirelli at post.com
Wed May 7 05:05:28 EDT 2008


   You must update to 4.0.7. You are probably facing the issues we had in
4.0.3.

   []s
   Edson

2008/5/7 Barath <barathguna at gmail.com>:

>
> Edson,
> I am using  4.0.3 version.
>
> In my code,
>  * For each thread new rule base and StatefulSession is created.
>  * Then why i am getting the previously mentioned exceptions(which i
> posted
> in the first message) for few    threads only while other works fine.
>  * Your suggestions please,
>     " 1 . Am i getting this error bcoz of the global list? or any other
> reason?
>      2 . How to solve this problem?"
>
> ~Barath.
>
>
> Edson Tirelli-3 wrote:
> >
> >    Barath,
> >
> >    What version of drools are you using?
> >
> >    The drools rulebase is designed to be shared among multiple threads.
> > The
> > working memory (session) is not.
> >    Having said that, we had a couple bugs in the past regarding
> > multi-thread
> > environments, and so you must use 4.0.7 version that is about to be
> > released. For you test, while you wait for the official release, you can
> > checkout the code and built it from here:
> >
> > http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/
> >
> >    []s
> >    Edson
> >
> > 2008/5/5 Barath <barathguna at gmail.com>:
> >
> >>
> >> Hi,
> >>
> >> While doing a load test with jmeter,my web service application with
> >> drools
> >> works fine for few clients(5 simultaneous hits for 10 times)
> >> but when i increase my clients(120 simultanious hits for 100 times) i
> am
> >> gettin the following exception for
> >> few client, (out of 12,000 hits 200 throws this exception)
> >>
> >> problem encountered at node [11] 5{170,189}: unable to resolve
> property:
> >> null pointer exception in property: declr.identifier
> >> org.mvel.TemplateInterpreter.execute(TemplateInterpreter.java:528)
> >> org.mvel.TemplateInterpreter.parse(TemplateInterpreter.java:341)
> >>
> >>
> org.drools.rule.builder.dialect.java.AbstractJavaBuilder.generatTemplates(AbstractJavaBuilder.java:113)
> >>
> >>
> org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:95)
> >> org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
> >> org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
> >> org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
> >>
> >>
> org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
> >> com.drools.util.RuleEngine.applyRule(RuleEngine.java:47)
> >>
> >>
> com.drools.util.DroolsController.getAdvertisement(DroolsController.java:94)
> >>
> >>
> com.drools.util.DroolsController.routeBusinessMethod(DroolsController.java:67)
> >>
> >>
> com.drools.util.DroolsController.getAdvertisement(DroolsController.java:43)
> >> com.drools.MyEndpoint.getAdvertisement(MyEndpoint.java:237)
> >> com.drools.MyEndpoint.process(MyEndpoint.java:144)
> >>
> >>
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
> >>
> >>
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
> >>
> >>
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> >>
> >>
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:595)
> >>
> >>
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
> >>
> >>
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
> >>
> >>
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> >>
> >>
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
> >>
> >>
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
> >> java.lang.Thread.run(Thread.java:619)
> >>
> >> drl file has 6 rules,
> >> 5 rules                   - which retract facts which passes the rule.
> >> 1 rule(low salience)  - will add the fact to java.util.List (set as
> >> global)
> >> which passes the rule.
> >>
> >> 1 . Am i getting this error bcoz of the global list? or any other
> reason?
> >> 2 . How to solve this problem?
> >>
> >> here the rules,
> >>
> >> <code>
> >> global java.util.List feasibleAdv;
> >>
> >> rule " percentage rule "
> >>    when
> >>        $adv : Advertisement( percentageLimit != 0 , percentageLimit <
> >> playedPercentage )
> >>    then
> >>        System.out.println("remove this adv (failed percentage):
> >> "+$adv.getAdvertisementID());
> >>        retract($adv);
> >> end
> >>
> >> rule "per day rule"
> >>    when
> >>        $adv : Advertisement( limitperday != 0 , limitperday <=
> >> playedperday
> >> )
> >>    then
> >>        //System.out.println("remove this adv (failed day):
> >> "+$adv.getAdvertisementID());
> >>        retract($adv);
> >> end
> >>
> >> rule "per week rule"
> >>    when
> >>        $adv : Advertisement( limitperweek != 0 , limitperweek <=
> >> playedperweek)
> >>    then
> >>        //System.out.println("remove this adv (failed week):
> >> "+$adv.getAdvertisementID());
> >>        retract($adv);
> >> end
> >>
> >> rule "per month rule"
> >>    when
> >>        $adv : Advertisement( limitpermonth != 0 , limitpermonth <=
> >> playedpermonth)
> >>    then
> >>        //System.out.println("remove this adv (failed month) :
> >> "+$adv.getAdvertisementID());
> >>        retract($adv);
> >> end
> >>
> >> rule "total played rule"
> >>    when
> >>        $adv : Advertisement( totallimit != 0 , totallimit <=
> totalplayed
> >> )
> >>    then
> >>        //System.out.println("remove this adv (failed total played) :
> >> "+$adv.getAdvertisementID());
> >>        retract($adv);
> >> end
> >>
> >>
> >> rule "advertisement select rule"
> >> salience -1
> >>        when
> >>                $adv : Advertisement( $playedPercentPerAdvertisement :
> >> playedPercentPerAdvertisement)
> >>                not( Advertisement( playedPercentPerAdvertisement <
> >> $playedPercentPerAdvertisement ) )
> >>                $advertisementCount : Integer()
> >>        then
> >>                boolean status = true;
> >>                if($advertisementCount-1 < 0){
> >>                        //System.out.println("halted");
> >>                        status = false;
> >>                        drools.halt();
> >>                }
> >>                if(status){
> >>                        feasibleAdv.add($adv);
> >>                        drools.update(
> >> drools.getWorkingMemory().getFactHandle($advertisementCount), new
> >> Integer($advertisementCount-1) );
> >>                        retract($adv);
> >>                }
> >> end
> >>
> >> </code>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Can-drools-work-in-multithreaded-environment--tp17053936p17053936.html
> >> Sent from the drools - user mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >
> >
> >
> > --
> > Edson Tirelli
> > JBoss Drools Core Development
> > Office: +55 11 3529-6000
> > Mobile: +55 11 9287-5646
> > JBoss, a division of Red Hat @ www.jboss.com
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Can-i-use-drools-in-multithreaded-environment--tp17053936p17097302.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080507/21d8461b/attachment.html 


More information about the rules-users mailing list