Using drool expert with dynamic decision tables

Here is what I wanted to do.

I wanted to add “rules” to the database table. This is similar to the drools xls decision table format, except that all rules will be rows in the table. That way, I can easily change the rules. I need to put this in a table, not in xls, because my rules can change often. Is this possible with saliva? Can I create a knowledge base with the rules obtained from the database (instead of a DRL or xls file), and with each change of rules I can rebuild the knowledge base from scratch (or maybe only part of the knowledge base, only those rules that significantly update changed ..)

+7
rule-engine drools
source share
1 answer

It depends on what rules you have in mind. The approach supported by the database makes sense if you have many rules that have the same structure and which depend only on certain “parameters”. In this case, you can write one general rule and use the database to store all applicable combinations. For example, suppose you have rules for calculating country delivery rates for an order, for example,

rule "Shipping rates to France" when $order : Order(country == 'fr') then $order.setShippingRate(10.0); update(order); end // Similar rules for other countries… 

You can replace this rule data from your database, where each CountryShippingRate indicates the speed for one country. Then you insert all CountryShippingRate rows as fact objects in the rules session and one rule, for example:

 rule "Shipping rates" when $order : Order($country : country) CountryShippingRate($rate : rate, country == $country) then $order.setShippingRate($rate); update(order); end 

In practice, it turns out that many rules such as decision tables can be rewritten in this way.

+6
source share

All Articles