Hello,
I have just started using Drools and already comes up against a tricky situation. Let me describe my use case in a very abstract way in order to formulate the question.
(i). If there is already an object objA of type A, create another obj2A of type A.
(ii).If there are more than one object of type A, create an object objB of type B.
I have two rules in my drl file checking the two situation in working memory ( rule1 and rule2 respectively). ( I have a check in .java side so this does not ends up in infinite loop). In the rules I am only using Drools query, and creating the object in java side.
So at first I create an objA of type A and put it in the working memory. Now I am firing the rules.
fire 1) There will be match for rule1 only, and I will create another object of type A and put in the working memory.
fire 2) Now the situation arrives where both of the rule matches.
*Here is my question*. Drools will check the rule1 again at fire 2, but I don't want this. I want it to check only rule2 and inform me if there is more than one object of type A in working memory. Is there a way to do this?
After some search I come up with AgendaFilter. But after reading about how AgendaFilter works, I have understood it will still check/evaluate both rules, and only restrict rule from firing according to my choice of filter. Is my understanding correct ?
Kindly suggest me how can I achieve this. Also let me know if I should provide some additional details.
Many thanks in advance.