Its just a hunch, but try your original code (not the pooling one) but pass the newStatefulKnowledgeSession to the constructor of the Thread sublass. -W
2011/10/11 Juan Carlos Fernández <juancarlos.fernan...@safelayer.com> > Here you have my pooling solution. Testing this source code reaches 100% > CPU > usage!! Used apache commons pooling. borrowObject() creates stateful > session > and pool it. returnObject() retracts all facts. > > Can we extract a conclusion with my tests? I'm going to implement pooling > solution inside my SOAP app and do performance tests (throughput). > > public class KnowledgeSessionThread extends Thread { > > int iterations = 500; > int numberFacts = 1000; > private ObjectPool pool; > > public KnowledgeSessionThread(ObjectPool pool) throws Exception { > this.pool = pool; > } > > public void run() { > try { > for( int i = 0; i < iterations; i++ ) { > StatefulKnowledgeSession session = > (StatefulKnowledgeSession)pool.borrowObject(); > for( int j = 0; j < numberFacts; j++ ) { > Message msg = new Message(); > msg.setMessage("Hello world"); > msg.setStatus(Message.HELLO); > session.insert(msg); > } > session.fireAllRules(); > pool.returnObject(session); > } > System.out.println("Thread finished " + > this.currentThread().getName()); > } catch( Exception e ) { > e.printStackTrace(); > } > } > } > > @Override > public Object makeObject() throws Exception { > System.out.println(Thread.currentThread().getName() + " - > makeObject() > called" ); > return kbase.newStatefulKnowledgeSession(); > } > > @Override > public void destroyObject( Object obj ) { > StatefulKnowledgeSession session = > (StatefulKnowledgeSession)obj; > session.dispose(); > > } > > @Override > public void passivateObject(Object obj) { > StatefulKnowledgeSession session = > (StatefulKnowledgeSession)obj; > for( FactHandle handle : session.getFactHandles() ) { > session.retract(handle); > } > } > > -- > View this message in context: > http://drools.46999.n3.nabble.com/StatefulKnowledgeSession-construction-executes-sequentially-no-multithread-tp3412107p3412338.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users