可以与 Spring Batch(500k 对象)结合使用的最佳规则框架是什么?
我在之前的项目中分别使用了 spring-batch 和 drools。在我当前的项目中,我有一个设计,需要处理多达 500k xml 对象,将它们转换为 jaxB,对每个对象应用规则(规则本身相当简单:比较属性并更新“通知”中的两个标志)对象),最后发送一个事件,以便 Spring Web Flow 视图模型(可以是侦听器)自行更新。这不是设计的要求,但这是我已经实现的: 1)项目阅读器(JaxB) 2) ItemProcessor:-映射到 ksession(有状态)并基于 drl 文件触发规则。 3)ItemWriter:准备必要的清理并引发适当的事件
在我看来,逻辑本身很简单,但是当我添加批处理作业的所有粘合代码:itemReader,Itemprocessor等时,一个简单的规则不起作用。另外,在阅读了几个论坛后,似乎 RETE 算法在批处理应用程序上无法很好地扩展。
总之,drools 是在 spring-batch 中集成基本规则框架的最佳方式还是有任何轻量级的替代方案?
I've used both spring-batch and drools on previous projects, separately. In my current project, I have a design where I need to process upto 500k xml objects, convert them to jaxB, apply rule on each of the object (the rule itself is fairly simple: compare properties and update two flags in a 'notification' object), and finally send an event so a spring web flow viewmodel (that can be a listener) will update itself. That's not the requirement for design but it's what I have implemented:
1) ItemReader (JaxB)
2) ItemProcessor:-maps to a ksession (stateful) and fires rules based on a drl file.
3) ItemWriter: prepares the necessary cleanup and raises appropriate events
Seems to me that the logic itself is straight forward, but when I added all the gluecode of batch job: itemReader, Itemprocessor, etc., a simple rule didn't work. Also, after reading several forums it seems RETE algo isn't going to scale well on batch applications.
In summary, is drools the best way to integrate a basic rules framework in spring-batch OR are there any light weight alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不需要任何
规则框架< /代码>。这就是 Spring Batch 的
ItemProcessor
的用途,来自
ItemProcessor
JavaDocs:“..一个允许应用业务逻辑的扩展点在面向项目的处理场景中”
不需要使用 Drools 或任何其他规则引擎使事情变得复杂,除非您确实需要它=>例如,有数十/数百个复杂的规则+,这些规则对于编码来说并不简单。
No need for any
Rules Framework
. That is what Spring Batch'sItemProcessor
is forfrom
ItemProcessor
JavaDocs:"..an extension point which allows for the application of business logic in an item oriented processing scenario"
No need to complicate things with Drools or any other rules engine, unless you really need it => e.g. have dozens / hundreds of complex rules + that are not trivial to code.
通常RETE算法不是问题而是一个巨大的优势。您需要在设计解决方案时假设它将是一个批处理过程并且可以正常工作。您需要考虑到您的场景中的巨大开销是从 XML 代码创建所有 500k 对象。一旦获得对象,如果正确设计业务规则,它将正确执行。
usually the RETE algorithm is not a problem is a huge advantage. You need to design your solution with the assumption that it will be a batch process and it will work fine. You need to take into account that the big overhead in your scenario is creating all the 500k objects from the XML code. Once you get the objects if you design your business rules correctly it will perform correctly.