数据驱动规则引擎 - 流口水 [英] Data Driven Rules Engine - Drools

查看:278
本文介绍了数据驱动规则引擎 - 流口水的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在评估Drools作为规则引擎用于我们的商业Web应用程序。

I have been evaluating Drools as a Rules Engine for use in our Business Web Application.

我的用例是订单管理应用程序。

规则属于以下类型:

- 如果用户类型为特殊,则额外提供5%折扣。

- 如果用户已制作10+已经购买,额外享受3%折扣。

- 如果产品类别为旧,请向价值5美元的用户赠送礼品篮。

- 如果产品类别为NEW,给价值1美元的用户赠送礼品篮
- 如果用户过去购物满1000美元,则免费送货

My use case is a Order Management Application.
And the rules are of following kind:
- If User Type is "SPECIAL" give an extra 5% discount.
- If User has made 10+ Purchases already, give an extra 3% discount.
- If Product Category is "OLD", give a Gift Hamper to the user worth $5.
- If Product Category is "NEW", give a Gift Hamper to the user worth $1
- If User has made purchases of over $1000 in the past, Shipping is Free

我看到的直接挑战是:

- 我无法向最终用户提供有意义的用户界面来修改规则。

- Guvnor UI或任何修改drl文件的编辑器从最终用户的角度来看是不可接受的。
- 这些规则中的大多数将对db中可用的大量数据进行操作

The immediate challenge i see is that:
- There is no meaningful UI that i can offer to the end users to modify the rules.
- Guvnor UI or any Editor to modify drl files is just not acceptable from end user point of view - Most of these Rules will operate on often huge data available in db

所以,


- 我希望管理员用户能够在我的Web App UI中指定这些规则。

- 我可以将这些规则存储在数据库中,然后通过Drools对它们进行操作 - 至少允许我通过自己的UI修改这些规则。所以这就像数据库中的决策表。

- 最好的方法是什么?

So,
- I want a way for Admin users to specify these Rule from within my Web App UI.
- Could i store these "Rules" in database, and then operate on them via Drools - at least that allows me to "modify" these Rules via my "own" UI. So this is something like a Decision Table in DB.
- What is the best way to go about this?

推荐答案

考虑到我对数据驱动的业务规则。我对这个问题的回答是,SQL是执行存储在数据库中的业务规则的错误解决方案。问这个问题的人想要从他们存储的业务规则中生成SQL表达式,我告诫不要这样做,因为这会导致安全性,可测试性,性能和维护方面的问题。

You asked me to give an answer to your question, given my answer to Data driven business rules. My answer to that question was that SQL is a bad solution to execute business rules stored in the database. The person who asked that question wanted to generate SQL expressions from their stored business rules, and I cautioned against doing that, because it would lead to problems in security, testability, performance, and maintenance.

我没有使用过Drools,但是我从文档中收集到它包含了一个业务规则管理器Guvnor,它支持将RDBMS用作用户定义规则的存储库

I have not used Drools, but I gather from documentation that it includes Guvnor, a business rules manager that supports using an RDBMS as a repository for user-defined rules.


[Drools] Guvnor使用JCR标准来存储规则等资产。默认实现是Apache Jackrabbit, http://jackrabbit.apache.org 。这包括现成的存储引擎/数据库,您可以按原样使用,或者根据需要配置为使用现有的RDBMS。 ( http:/ /docs.jboss.org/drools/release/5.2.0.Final/drools-guvnor-docs/html/chap-database_configuration.html

[Drools] Guvnor uses the JCR standard for storing assets such as rules. The default implementation is Apache Jackrabbit, http://jackrabbit.apache.org. This includes an out of the box storage engine/database, which you can use as is, or configure to use an existing RDBMS if needed. (http://docs.jboss.org/drools/release/5.2.0.Final/drools-guvnor-docs/html/chap-database_configuration.html)

Apache Jackrabbit不是RDBMS,它是内容存储库是一个分层内容存储库,支持结构化和非结构化内容,全文搜索,版本控制,事务,观察等。对于Drools来说,这似乎是一个更合适的存储库。

Apache Jackrabbit is not an RDBMS, it is "a content repository is a hierarchical content store with support for structured and unstructured content, full text search, versioning, transactions, observation, and more." This seems like a more appropriate repository for Drools.

但是Drools并没有说它试图使用SQL来执行这些业务规则。它有一个单独的组件, Drools Expert(规则引擎)来做到这一点。

But Drools doesn't say it tries to use SQL to execute those business rules. It has a separate component, Drools Expert (Rules Engine) to do that.


Drools Expert是一个声明,基于规则,编码环境。这使您可以专注于你想做什么,而不是如何做到这一点。
http://www.jboss.org/drools/drools-expert .html

SQL也是一种声明性编程语言,但它旨在对表结构数据执行关系操作。实现规则引擎的语言有不同的目标,可能会做SQL无法做到的事情(反之亦然)。

SQL is also a declarative programming language, but it's designed to perform relational operations on table-structured data. A language to implement a rules engine has different goals, and can probably do things that SQL can't (and vice-versa).

所以我建议你使用Drools,随意使用RDBMS作为存储库(使用他们的JCR兼容的内容存储库实现,不要试图设计自己的)。然后使用他们的Drools Expert作为专门用于执行规则的语言。

So I would suggest if you use Drools, feel free to use an RDBMS as a repository as they document (use their JCR-compliant implementation of content repository, do not try to design your own). Then use their Drools Expert as a specialized language designed for executing rules.

这篇关于数据驱动规则引擎 - 流口水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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