从规则中获取事实清单 [英] Get list of facts from rule

查看:98
本文介绍了从规则中获取事实清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有1000条流口水的规则和20条客户。我要解雇那些特定于客户的规则。一条规则可能不仅适用于客户,而且适用于更多客户。我知道哪个客户正在使用该应用程序,因此基于此我想获取适用于该客户的规则列表以及我需要从数据库获取以启动这些规则的事实列表。
首先获得两个列表之后,我将从db中获取值,然后触发该特定客户的所有规则。

解决方案

最好的解决方法是使用一些智能包装。将客户独有的规则放在自己的程序包中。可以在其他程序包中放置不同的共享规则集。



例如,您可以如下定义kbase:



< pre class = lang-xml prettyprint-override> <?xml version = 1.0 encoding = UTF-8?>
< kmodule
xmlns = http://jboss.org/kie/6.0.0/kmodule>
< kbase name = acme
packages = com.dunder.rules.acme,com.dunder.rules.paper>
< ksession name = acmeSession type = stateless />
< / kbase>
< kbase name = pipepiper
package = com.dunder.rules.pipepiper,com.dunder.rules.paper>
< ksession name = piedpiperSession type = stateless />
< / kbase>
< / kmodule>

以上将同时使用纸张规则的 Acme和 Pied Piper规则


Suppose I have 1000 rules in drool and 20 customers. I want to fire those rules which are specific to a customer. It is possible that one rule is applicable for more than on customer. I know which customer is using the application so based on that I want to get list of rules applicable for the customer and list of the facts I need to get from the db to fire those rules. After getting both lists first I'll get the values from db and than fire all the rules for that particular customer.

解决方案

The best way forward here is to use some smart packaging. Place rules exclusive to a customer in their own package. Different sets of shared rules can be placed in other packages.

You would for example define the kbases as follows:

<?xml version="1.0" encoding="UTF-8"?>
<kmodule
        xmlns="http://jboss.org/kie/6.0.0/kmodule">
    <kbase name="acme" 
           packages="com.dunder.rules.acme, com.dunder.rules.paper">
        <ksession name="acmeSession" type="stateless"/>
    </kbase>
    <kbase name="pipepiper" 
           packages="com.dunder.rules.pipepiper, com.dunder.rules.paper">
        <ksession name="piedpiperSession"type="stateless" />
    </kbase>
</kmodule>

The above would have rules for "Acme" and "Pied Piper" while both using "Paper" rules.

这篇关于从规则中获取事实清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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