jbossdroolsrule-engine

Droos Rule Engine - Calling a utility function integrated with database from .drl file


I have a scenario if the fact contains a particular value, then I wanted to call a utility function which will invoke the database and populate some values for fields. Is it okay to call data base function from the utility class which is invoked from drl file?


Solution

  • as a general answer, you can call a db fonction in the action part (then part) of your rule to update your Working Memory objects

    However, you'll have to notify Drools this object has been modified using update keyword see DRL Then reference

    I would strongly advice against calling a db method in the condition (if part) of the rule, as such methods can be called many times unknowingly.

    Best

    Emmanuel