« Return to Thread: Can i use drools in multithreaded environment?

Can i use drools in multithreaded environment?

by Barath () :: Rate this Message:

Reply to Author | View in Thread

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,


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

Thanks,
~Barath.

 « Return to Thread: Can i use drools in multithreaded environment?