简体   繁体   English

是newKieSession线程安全吗?

[英]is newKieSession thread-safe?

We used Drools kieSessions in our project. 我们在项目中使用了Drools kieSessions。 Many threads can create new kieSession. 许多线程可以创建新的kieSession。 Sometimes thread can hang while creating session. 有时线程可以在创建会话时挂起。 Hence the question: 因此问题是:

Firstly 首先

  1. is kieContainer.newKieSession thread-safe operation? 是kieContainer.newKieSession线程安全操作?
  2. Can the reason of hanging be a dirty writing or reading the collection of kie sessions or something like that? 悬挂的原因可能是肮脏的写作或阅读kie会话或类似的东西?

As I checked in practice 当我在实践中检查

newKieSession

isn't thread-safe operation. 不是线程安全的操作。

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). 我在drools文档中找不到任何明确的声明,但我的理解是KieContainer是线程安全的,甚至足够智能(有点默默/神奇地)更新自己(或者更确切地说它包含的KieBases)。

For all practical purposes (debugging/reading the source code) I think all the KieContainer.newStatelessKieSession() and the KieContainer.newKieSession() methods are thread-safe. 出于所有实际目的(调试/读取源代码),我认为所有KieContainer.newStatelessKieSession()KieContainer.newKieSession()方法都是线程安全的。

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. 我不是100%确定updateToVersion()updateDependencyToVersion()方法,以及是否通过与KieContainer.newStatelessKieSession()newKieSession()方法并行更改kie容器。

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. 在我们的应用程序中,我们设法将规则(以及模块,基础,会话及其配置)的修改逻辑从规则评估(使用newKieSession等方法)中分离出来,到目前为止看似很好,但我想要了解你是如何得出它不是线程安全的结论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM