使用 drools Expert 和动态决策表
这就是我想做的事情。
我想将“规则”放入数据库表中。这有点像 drools xls 决策表格式,只不过所有规则都是表中的行。这样我就可以轻松修改规则了。我需要将其放入表格而不是 xls 中,因为我的规则可能会经常更改。流口水可以做到这一点吗?我可以使用从数据库(而不是 DRL 或 xls 文件)检索的规则来构建知识库吗?每次规则更改时,我可以从头开始重建知识库(或者可能只是知识库的一部分,本质上只更新那些已更改的规则) ..)
Here's what I had like to do.
I had like to put "rules" in a database table. This is sort of like the drools xls decision table format except that all the rules will be rows in a table. This way I can modify the rules easily . I need to put this in a table and not an xls because my rules could be frequently changing. Is this possible with drools? Can I build a knowledgebase with rules retrieved from a DB (instead of a DRL or a xls file) and every time rules change can I rebuild the knowledge base from scratch (or maybe just parts of the knowledgebase, essentially update only those rules that's changed..)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于您心中的规则。如果您有许多具有相同结构且仅根据某些“参数”而变化的规则,则数据库支持的方法是有意义的。在这种情况下,您可以编写单个通用规则,并使用数据库来存储所有适用的组合。例如,假设您有一个规则来计算某个订单的每个国家/地区的运费,例如,
您可以替换数据库中的这些规则数据,其中每个
CountryShippingRate
指定一个国家/地区的费率。然后,将所有CountryShippingRate
行作为事实对象插入规则会话中,并插入一条规则,例如:在实践中,事实证明,可以通过这种方式重写许多决策表类型规则。
It depends on what kind of rules you have in mind. A database-backed approach makes sense if you have lots of rules that have the same structure, and which only vary according to certain 'parameters'. In this case you can write a single generic rule, and use the database to store all of the combinations that apply. For example, suppose you have a rules to calculate shipping rates per country, for an order, e.g.
You could replace these rules data from your database where each
CountryShippingRate
specifies the rate for one country. Then you insert all of theCountryShippingRate
rows as fact objects in the rule session, and a single rule, like:In practice, it turns out that lots of decision table type rules can be rewritten this way.