27459

is newKieSession thread-safe?

Question:

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

newKieSession

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 updateToVersion() and updateDependencyToVersion() methods and whether changing the kie container through those works in parallel with the KieContainer.newStatelessKieSession() and newKieSession() methods.

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.

Recommend

  • How to change front end of kie workbench of jbpm 6.5?
  • using single AE title to more than one Ipaddress
  • Gradle Drools 6.2 Could not resolve all dependencies for configuration ':compile'
  • Visual Studio 2017 hangs while loading a solution
  • How run two Chrome driver for one profile with Selenium Webdriver Nodejs?
  • NServiceBus error handling
  • Extend Google Maps Bounds so that div overlay doesn't cover any markers
  • how to make NSManagedObjectContext dirty (hasChanges = YES) Manually
  • Issue with session.handler.native_file session handler in symfony2
  • PHP Post & Redirect with cURL Same As HTML Form [closed]
  • How do I unit test for machine specific behaviour?
  • IP and domain create different session
  • Rewrite apply function to use recursion instead
  • Git and client/server code separation
  • python regex split string while keeping delimiter with value
  • jQuery and Uploadify session in the php file
  • How to distribute an event to all nodes in a (Wildfly) cluster?
  • Allocating a 2D contiguous array within a function
  • Refactoring advice: maps to POJOs
  • Possible to get the line number of the currently executing sproc in SQL Server?
  • Where these are stored?
  • abstracting over a collection
  • Error in installing package: fatal error: stdlib.h: no such file or directory
  • How can I tell a form not to dispose a particular control when it closes?
  • Set focus to first invalid form element in AngularJS
  • Clear activity stack before launching another activity
  • How to make R's read_csv2() recognise the text characters properly
  • Azure table store snapshot/backup capability
  • How to make JSON.NET deserialize to Microsoft Date Time?
  • How to get current document uri in XSLT?
  • SharedPreferences or SQLite Database?
  • Assign variable to the value in HTML
  • Installed module is empty
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Deselecting radio buttons while keeping the View Model in synch
  • Nant, Vault & Windows Integrated Authentication
  • retrieve vertices with no linked edge in arangodb
  • How to disable jQuery.jplayer autoplay?
  • SQL merge duplicate rows and join values that are different
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed