j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.83k stars 1.04k forks source link

How to set the Priority of the Rule at runtime #382

Open deepaksmailgithub opened 2 years ago

deepaksmailgithub commented 2 years ago

Hi,

I am having issue setting the priority of the rule at runtime. I know if I use RuleBuilder, I can set the priority, but then I have to override the when and then and then build the rule. But in my case, I am getting the list of rules name (to be executed) at run time and the user can specify the order of these rules should be executed. Can you please provide some guidance on how to implement this? I am using the annotation at the Rule component creation like @Rule(name = "SomeRule", description = "Description of Rule User", priority = 2), the priority of this is hardcoded, and I want to someway set this priority at run time.

Thanks, DS

dvgaba commented 2 years ago

I think keeping priority of the rules same and then change order before execution should work for you.

alishaarora commented 4 months ago

@dvgaba Can you share an example? How can we change the order before execution?