Hello,
I encountered the same problem with him about concurrency. This is the url to this question.
https://developer.jboss.org/message/829335#829335
I use thread to run drools,and version is 6.5.0.Final. This will cause a calculation error. Looked at your answer, I used threadLocal to create kieSession. The results of the test were very successful. But I would like to know if there is a better solution to solve this problem.
This is part of the code:
@Component
@Scope("prototype")
public class ThreadLocalUtils {
/**
* @function getKieSession
*/
public KieSession getKieSession(ThreadLocal<KieSession> tl, String kSessionName) {
KieSession kieSessionFirstLoan = null;
try {
KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
kieSessionFirstLoan = kContainer.newKieSession(kSessionName);
} catch (Exception e) {
e.printStackTrace();
}
KieSession c = tl.get();
if (null == c)
tl.set(kieSessionFirstLoan);
return tl.get();
}
}
Hello, I encountered the same problem with him about concurrency. This is the url to this question. https://developer.jboss.org/message/829335#829335 I use thread to run drools,and version is 6.5.0.Final. This will cause a calculation error. Looked at your answer, I used threadLocal to create kieSession. The results of the test were very successful. But I would like to know if there is a better solution to solve this problem. This is part of the code:
Thanks & Regards. zhangwei