KieSession.insert() 和 KieSession.fireAllRules() 是线程安全的吗?

Is KieSession.insert() and KieSession.fireAllRules() thread-safe?

我正在使用 DroolsSpring Boot。在我的项目中,我正在制作 KieSessionKieContainerKieServices 的单例 Bean。 KieSession 将用于不同的单例服务和控制器。我想知道 KieSesion.insert()KieSession.fireAllRules() 是否是 线程安全的 单例 bean 实现。或者我应该创建一个实用程序 class 具有 synchronized 访问 KieSesion.insert() 和 KieSession.fireAllRules()?

KieSession 自 Drools 6 以来一直是线程安全的,从 manual

Engine’s code dealing with multi-threading has been partially rewritten in order to remove a large number of synchronisation points and improve stability and predictability. In particular this new implementation allows a clearer separation and better interaction between the User thread (performing the insert/update/delete actions on the session), the Drools engine thread (doing the proper rules evaluation) and the Timer one (performing time-based actions like events expiration).

7.52.0.Final 起,如果不需要获得一些性能,用户可以禁用线程安全。这是 relevant 发行说明:

As per the default configuration, a KieSession is thread-safe and can be shared safely and used by multiple threads at the same time. However, if a KieSession is running, it requires additional synchronization points to support the thread-safety, which is not required, and eventually, it slows the performance of the KieSession. Therefore, a new ThreadSafeOption is introduced, which you can use to optionally disable the thread-safety. The ThreadSafeOption consists of two values including YES (default) and NO.