0

I'm currently using Drools in a software application to validate a significant number of data objects. The creation process involves multiple steps, and at each step, Drools rulesets are employed to validate the objects being created. These validated objects eventually become properties of the final data object.

Whenever a rule is triggered during this validation process, it necessitates user approval and is subsequently saved to the database along with the object. However, these data objects can be updated at any given time. To optimize the system, I want to prevent rules from being retriggered so that less manual approval is required if the property of the model object that was involved in calculation in the previously saved rule remains unchanged.

My requirement can be visualized into diagram as below:

Process diagram

Stateful session can not be used for my case since it will hode an active session for each object. My system will have millions of objects to be validated and the number keeps increasing.

To achieve this, I'm seeking a solution that allows me to save the triggered rule and its evaluation arguments or calculation processes to the database. Consequently, when the object is passed in again, I can compare the evaluation arguments or calculation processes and determine if they are the same. If they are, I can consider the rule's property as unchanged.

Unfortunately, I've hit a roadblock as I can't find a way to retrieve the evaluation arguments in Drools. Therefore, I'm inquiring if there is a way to accomplish this within the Drools framework or if there are alternative technologies that could fulfill this requirement. Any guidance would be greatly appreciated.

I read documentations, checked the source code, printed the trace logs, asked chatgpt, none of them helped.

Roddy of the Frozen Peas
  • 14,380
  • 9
  • 49
  • 99
  • This sounds like a problem that should be solved outside of Drools. Save the entity and a record of rules fired when the user first approves. When the entity is updated, fire the rules a second time -- if the entity and the rules fired are the same as they were in your previous run, don't re-ask for approval. The obvious breakdown is that the current mechanism where the user always has to approve allows for the rules to change, whereas any caching mechanism requires them to be static. – Roddy of the Frozen Peas Jul 13 '23 at 13:44
  • Hi Roddy @RoddyoftheFrozenPeas, Thank you for your reply. Your suggestion is exactly what I am doing. And what I am looking for is a way to determine if the entities are the same. To be more precise, I need a way to determine if the entity properties which are directly participating comparison has been changed. If the change is on other fields not used in comparison, it should be treated as unchanged. That is why I would like to retrieve the evaluation arguments/process from the drools. Or in other words, I want not just the result, but also the steps. – skyman lee Jul 13 '23 at 14:32
  • Determining if those entities are the same is not a question we can answer, it depends on your model and what you consider to be the "same". Just because you evaluates fields A, B, and C in the past means nothing is your rules have changed; maybe we no longer care about C but have additional validation for D. Or possibly the B check was just a null check before but is now more complex. – Roddy of the Frozen Peas Jul 13 '23 at 20:01
  • @RoddyoftheFrozenPeas Thanks again. In fact, the difficult is about finding out what fields are involved in the comparison, and there is no way I can find it out without low level support from Drools. I thought maybe I can find it from the trace of comparison, but I don't see Drools provide it in anyway. – skyman lee Jul 13 '23 at 21:50
  • You could probably write listeners yourself but it would negatively impact your throughput and performance significantly. And as I said, even if the fields _were_ available, they wouldn't be sufficient because perhaps the actual checks done against those fields have changed. – Roddy of the Frozen Peas Jul 14 '23 at 13:31
  • @RoddyoftheFrozenPeas Hi Roddy, may I ask what kind of listener would it be? Is it AgendaEventListener or something similar? I probably will give it a try if it works, given the fact that it would negatively impact the performance. Thanks. – skyman lee Jul 17 '23 at 15:06

0 Answers0