We used Drools kieSessions in our project. Many threads can create new kieSession. Sometimes thread can hang while creating session. Hence the question:
Firstly<ol><li>is kieContainer.newKieSession thread-safe operation?</li> <li>Can the reason of hanging be a dirty writing or reading the collection of kie sessions or something like that?</li> </ol>Answer1:
As I checked in practice
isn't thread-safe operation.Answer2:
I couldn't find any explicit statement in the drools documentation, but my understanding is that the
KieContainer is thread-safe and even smart enough to (somewhat silently/magically) update itself (or rather its contained KieBases).
For all practical purposes (debugging/reading the source code) I think all the
KieContainer.newStatelessKieSession() and the
KieContainer.newKieSession() methods are thread-safe.
I am not 100% sure about the
updateDependencyToVersion() methods and whether changing the kie container through those works in parallel with the
In our application we managed to separate the logic of modifying your rules (and modules, bases, sessions and their configuration) from the rule evaluation (which uses the
newKieSession etc methods) and things seem to be fine so far, but I'd like to understand how you came to the conclusion that it isnt thread-safe.