开发者

Is it possible to add a new rule to a running Drools session?

开发者 https://www.devze.com 2023-01-28 21:59 出处:网络
Hey there, I\'ve got a project at work that may require me to load/unload rules to 开发者_如何学JAVAa stateful Drools session during the run of the program. (Eventually using JMX, but for now I\'m jus

Hey there, I've got a project at work that may require me to load/unload rules to 开发者_如何学JAVAa stateful Drools session during the run of the program. (Eventually using JMX, but for now I'm just trying to add a rule to a ready-made session)

I was wondering, is this possible and in that case how? Do I need to rebuild the session? I have attempted to simply get the knowledge base from the session, add my rule file to it and then fire all rules, which didn't work.

Thanks!


Short answer is YES, here's a quote from the documentation:

3.2.5. StatefulknowledgeSessions and KnowledgeBase Modifications

Stateful Knowledge Sessions will be discussed in more detail in section "Running". The KnowledgeBase creates and returns StatefulKnowledgeSession objects, and it may optionally keep references to those. When KnowledgeBase modifications occur those modifications are applied against the data in the sessions. This reference is a weak reference and it is also optional, which is controlled by a boolean flag.

0

精彩评论

暂无评论...
验证码 换一张
取 消