Is the new KieSession thread safe?

We used Drools kieSessions in our project. Many threads can create new kieSessions. Sometimes the thread can hang while creating a session. Hence the question:


  • is kieContainer.newKieSession safe operation?
  • Could the reason for the hang be dirty writing or reading a collection of kie sessions or something like that?

source to share

2 answers

As I tested in practice



does not work in streaming mode.



I couldn't find any explicit instruction in the descent documentation, but I understand that it KieContainer

is thread safe and even smart enough to (somewhat quietly / magically) update itself (or rather the KieBases it contains).

I think that all methods for all practical purposes (debugging / source code reading) KieContainer.newStatelessKieSession()

and KieContainer.newKieSession()

are thread safe.

I'm not 100% sure about the methods updateToVersion()

and updateDependencyToVersion()

and whether I change the kie container through those that work in parallel with the methods KieContainer.newStatelessKieSession()

and newKieSession()


In our application, we managed to separate the logic for changing your rules (and modules, bases, sessions and their configuration) from the rule evaluation (which uses methods newKieSession

, etc.), and so far everything seems fine, but I would like to understand how you came to concluding that it is not thread safe.



All Articles