Get list of facts from rule

柔情痞子 提交于 2019-12-13 10:38:22

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/38626569/get-list-of-facts-from-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!