[rules-users] Advantages and Disadvantages of "from"

Marcus Ilgner marcus.ilgner at gmail.com
Fri May 30 11:38:12 EDT 2008


Hi,


On Fri, May 30, 2008 at 5:06 PM, Thalupula Ravi <thalupularavi at gmail.com> wrote:
>
> Hi,
>
> Can some one describe about advantages and disadvantages of below to
> approaches
>
> 1. Interacting Database for information in rule ( using "from" or something
> else)?
>
> or
>
> 2. Required information supplied to rules in the form facts at one shot by
> client instead of again hitting the database.
>
> Thanks for your help:handshake:

if you're going to use "from" in your rules, you should make sure that
you provide some extra methods in your DAOs instead of only some
generic "getAll()" method. This way, if there are some hundred
thousands records in your database, Drools will not have to
instantiate an object for each of them since the DAO/database can
filter out those objects that are not relevant to the use case.
If, for example, you write some rule that handles order processing,
you could write a DAO method "getUnprocessedOrders()" which will
ignore all orders that are already processed. AFAIK Drools does no
sharing/caching of objects retrieved via equivalent "from" calls in
different rules.
When planning my current project, I quickly found that manually
retrieving the objects and inserting them into the working memory gave
me somewhat more flexibility but that of course depends on the use
case at hand.

Best regards
Marcus



More information about the rules-users mailing list