流口水无状态与有状态会话 [英] drools stateless vs stateful session

查看:105
本文介绍了流口水无状态与有状态会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该何时使用Drools无状态会话,而使用它代替有状态会话有什么好处?

在某些注释中这里据说无状态会话包装了一个有状态会话,这是否意味着当我解雇所有规则后将statfeul会话记为story时,它的行为就像一个有状态会话吗?

When should I use Drools stateless session and what are the benefits of using it instead of stateful session?
In some comment here it's said that stateless sessions wraps a stateful one, does it means that when I destory the statfeul session after firing all rules would behave like a stateful one ?

推荐答案

也许最好说(有状态的)KieSession和StatelessKieSessions都为基于类AbstractRuntime的类提供API(接口)。

Perhaps it would be better to say that both (stateful) KieSession and StatelessKieSessions provide APIs (interfaces) to classes based on class AbstractRuntime.

StatelessKieSession提供了一个接口,用于通过单个 execute 方法调用来执行一组命令,这些命令表示为一组对象。如果要将命令发送到远程会话,则很有用(但如果在应用程序中运行会话,则不需要)。同样,这样的会话将不会对工作内存中所做的更改做出反应,因此尽管它可能比有状态会话执行第一轮也是唯一一轮,但它的作用是有限的。

A StatelessKieSession provides an interface for executing a set of commands via a single execute method call, commands being represented as a set of objects. This is useful if you want to send commands to a remote session (but not if you run the session within your application). Also, such a session will not react to changes done within Working Memory, so its usefulness is limited, although it might perform the first and only round more efficient than a stateful session.

执行 调用意味着 dispose 调用,这是对会话对象的最后告别:将所有资源释放到

An execute call implies a dispose call, which is the final goodbye to the session object: release all resources into garbage collection.

总结(在Drools文档中有完整描述)

To summarize (what is described in full in the Drools documentation)


  • 对于简单的规则评估,尤其是通过某些远程通信,请使用无状态会话。

  • 要充分利用生产系统的全部功能,即继续重新评估规则条件由于事实的改变和事实阵容的改变,有必要使用有状态会话。

不要担心好处 (如果您打算使用简单的应用程序界面:只需使用有状态会话即可。

Don't worry about "benefits" if you are planning for a simple application interface: just use a stateful session.

这篇关于流口水无状态与有状态会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆