在 Web 应用程序中使用 Drools Expert/Flow 的最佳实践

发布于 2024-09-25 23:26:23 字数 468 浏览 8 评论 0原文

我目前正在自学 Drools Expert/Flow 以及 GWT。我想使用 Drools Flow 作为事件/命令总线和业务规则引擎来实现应用程序不同部分之间的松耦合。

到目前为止,我已经从我的测试用例中获得了 Expert 和 Flow,但我很难弄清楚如何在 Web 容器中最好地实现 Flow。

我是否应该将所有脚手架放入无状态会话 EJB 中,并让每个请求从头开始设置所有内容,然后运行流程/规则?对我来说这似乎是一种资源浪费。我是否可以存储单个知识会话并在 Web 请求之间共享该会话,同时访问它,该场景是否可以扩展并且线程是否安全(我的猜测是否定的)?汇集知识课程是个好主意吗?

我想问的基本上是上述内容是否有任何最佳实践?文档和示例虽然在其他方面都很好,但在这些特定点上并不清楚。

我确实读过一些关于 Drools Grid 的内容,不确定这是否能解决我的问题,而且似乎正在开发中。如果我的问题不清楚,请说出来。

BR马格努斯

I'm currently teaching myself Drools Expert/Flow as well as GWT. I want to use Drools Flow as an event/command bus and business rule engine to achieve loose coupling between different parts of the application.

So far I've gotten both Expert and Flow working from my test cases, but I have a hard time figuring how to best implement Flows within a web container.

Should I put all the scaffolding into an Stateless Session EJB and let each request set up everything from scratch and then run the flows/rules? This seems like a waste of resources to me. Can I instead store a single knowledge session and share that sessions between web requests, accessing it concurrently, would that scenario scale and is it thread safe (my guess is no)? Is pooling knowledge sessions a good idea?

What I'm asking for is basically if there is any best practices for the above? The documentation and examples, while otherwise quite good, are not clear on these particular points.

I did read something about Drools Grid, not sure if that would solve my problem and that seems to be under development. If my questions are unclear, please say so.

BR Magnus

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杯敬自由 2024-10-02 23:26:24

知识库是线程安全且重量级的(创建起来并不便宜),因此您可能希望将其保留在应用程序范围内。

目前,大多数人倾向于使用无状态架构,并为每个 Web 请求创建 StatelessKnowlegdeSession(线程不安全且创建成本低),例如在无状态会话 bean(或 seam/CDI bean 或 spring bean)中。
然而,如果您拥有有状态 EJB 的强大功能,那么继续使用一个 StafefulKnowlegdeSession 来处理同一对话中的所有请求可能会很有意义。

我不确定 StatefulKnowlegdeSession 是否是线程安全的(不这么认为),
所以我提出了一个问题: https://issues.jboss.org/browse/JBRULES-2842

A KnowledgeBase is thread safe and heavy weight (it's not cheap to create), so you 'll probably want to keep that in an application scope.

For now, most people tend to use a stateless architecture and create a StatelessKnowlegdeSession (thread unsafe and cheap to create) for every web request, for example in a stateless session bean (or a seam/CDI bean or a spring bean).
However, if you have the power of stateful EJB's, it can be rewarding to keep use one StafefulKnowlegdeSession to handle all requests in the same conversation.

I am not sure if StatefulKnowlegdeSession is thread safe (don't think so),
so I made an issue: https://issues.jboss.org/browse/JBRULES-2842

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文