Rules Execution Dynamically

171 views
Skip to first unread message

Deepak Sharma

unread,
Feb 21, 2023, 12:03:23 AM2/21/23
to Drools Setup
Hi,
I am very new to Drools and got a basic understanding of running Drools using latest version 8.33.0 in a spring boot application to fire basic rules using .drl file. I have few doubts/queries and would be thankful if this mindful community can help me to learn it more by answering below queries:

- How we can execute rules using Drools at runtime.
- Is it good practice to keep rules into Database.
- How to run multiple .drl files into same application (module wise) like payments, customers, mortgage, etc.
- In which scenario we should use multiple sessions/ containers to execute rules.

Thank you
Regards
Deepak 

Toshiya Kobayashi

unread,
Mar 17, 2023, 4:38:34 AM3/17/23
to Drools Setup
Hello,


> - How we can execute rules using Drools at runtime.

Do you mean a simple usage?

You can find it in getting started section (latest version 8, RuleUnit API).

https://docs.drools.org/latest/drools-docs/docs-website/drools/getting-started/index.html#first-rule-project_getting-started

Or this blog post is based on a little old version (7.61.0, traditional API), but contains various examples.

https://blog.kie.org/2021/11/drools-basic-examples.html


> - Is it good practice to keep rules into Database.

An usual practice is to manage rules with version control system and build them with kie-maven-plugin to create a kjar.

But I see some users keep rules into database and build them programmatically.


> - How to run multiple .drl files into same application (module wise) like payments, customers, mortgage, etc.

It's just fine to have multiple .drl files and build a kbase. Also you may split them to multiple kbases if those rules are logically separated.


> - In which scenario we should use multiple sessions/ containers to execute rules.

Firstly, it's common to create multiple sessions when you handle multiple web requests concurrently.

If you think about using multiple sessions for one request, it may be the case which I described above as multiple kbases. In that case, you would create one ksession from one kbase.

I hope this helps.

Regards,
Toshiya

2023年2月21日火曜日 14:03:23 UTC+9 Deepak Sharma:
Reply all
Reply to author
Forward
0 new messages