简体   繁体   English

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

[英]Best practices for using Drools Expert/Flow in a Web Application

I'm currently teaching myself Drools Expert/Flow as well as GWT. 我目前正在教自己Drools Expert / Flow以及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. 我想使用Drools Flow作为事件/命令总线和业务规则引擎来实现应用程序不同部分之间的松散耦合。

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. 到目前为止,我已经从我的测试用例中获得了Expert和Flow,但是我很难确定如何在Web容器中最好地实现Flow。

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? 我是否应该将所有脚手架放入无状态会话EJB并让每个请求从头开始设置所有内容然后运行流/规则? 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)? 我是否可以存储单个知识会话并在Web请求之间共享该会话,同时访问它,该方案是否可以扩展并且是否是线程安全的(我的猜测是否定的)? 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. 我确实读过一些关于Drools Grid的东西,不确定这是否能解决我的问题,而且似乎正在开发中。 If my questions are unclear, please say so. 如果我的问题不清楚,请说出来。

BR Magnus BR Magnus

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). 目前,大多数人倾向于使用无状态架构并为每个Web请求创建StatelessKnowlegdeSession(线程不安全且创建便宜),例如在无状态会话bean(或者seam / CDI bean或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. 但是,如果您具有有状态EJB的强大功能,那么继续使用一个StafefulKnowlegdeSession来处理同一对话中的所有请求都是有益的。

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

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

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