Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
586 views
in Technique[技术] by (71.8m points)

drools - Get list of facts from rule

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...