How to make the LHS and RHS dynamically? How to generate DRI dynamically?

948 views
Skip to first unread message

DroolsLier

unread,
May 25, 2015, 12:54:24 PM5/25/15
to drools...@googlegroups.com
Dear All,
We have a requirement the similar thing might have different LHS and RHS based on different config. I checked the drools document, it looks like we can maintain  hundreds DRI files to get this done. I'm planning put the LHS and RHS into the database and then maintain just one DRI file or no file to dynamically generate the rules and fire them. I tried to put the LHS into one field of  the fact and check this field using the eval(), it seems not working.

Checking the related topics, there are mentioned similar cases, there are 3 major options:
1) Using the string to dynamically build rule and store the whole string into the DB or using the API dynamically create rules;
2) Keep one DRI file and put the placeholding into the LHS and RHS and replace the placeholder using the velocity or any other template framework;
3) Using drools template if the fields are fixed

I'm wondering if there is any other more elegant way can make this happen? How you guys make your drools development? How many DRI files do you have to maintain?

http://drools-moved.46999.n3.nabble.com/Writing-rules-using-java-td57894.html
http://drools-moved.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-td3772708.html


Thanks,
Shawn

Mark Proctor

unread,
May 25, 2015, 1:25:30 PM5/25/15
to drools...@googlegroups.com
My recommendation is to create your own model and generate rules using MVEL templating, which is already a dependency of Drools.

Mark
--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/a83dd1f2-5c6d-4d6d-a8e0-81f40980b29d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

DroolsLier

unread,
May 25, 2015, 11:00:40 PM5/25/15
to drools...@googlegroups.com
Thanks for your prompt reply, Mark.

Could you elaborate a little bit? What's the model used for? Do you mean dynamically generate rules using MVEL templating?

My case is the rule is predefined, but just the LHS might different in different cases, the RHS should be something similar. It looks like just using the MVEL templating can meet my requirement but it will loose the Drools rule management features.

Sundar M

unread,
Jun 1, 2015, 6:40:49 AM6/1/15
to drools...@googlegroups.com
Hi DroolsLier,

Tried to use DRT for generating rules dynamically based on the configuration in database.

http://docs.codehaus.org/display/DROOLS/Loading+and+managing+rules+dynamically+from+a+database
Reply all
Reply to author
Forward
0 new messages