-
1. Re: fireAllRules() in a loop issue
salaboy21 Feb 3, 2012 1:15 PM (in response to milhaim)what are you trying to achieve in the first place? that rule is not checking for nothing.. so the first time it fires.. but nothing changes.. so it will not fire again..
Try to explain to us what are you trying to achieve, because that doesn't seems like a good solution.
Cheers
-
2. Re: fireAllRules() in a loop issue
milhaim Feb 3, 2012 1:35 PM (in response to salaboy21)Many thanks for your reply,
I have this issue in a more complex process, so I simplified the process for test purposes,
Basically what I want to do is each time I create a human task, a rule check if a max number has been reached, if this is the case the rule do some actions.
my first test was to chek if the some rule can be activated many times for the some process instance, and how to do it.
have a good weekend,
Cheers,
-
3. Re: fireAllRules() in a loop issue
swiderski.maciej Feb 4, 2012 1:41 PM (in response to milhaim)Rule must be activated (on agenda) to be eligible for invocation by fireAllRules, so multiple invocation of fireAllRules without modification to the session will not have any consequence. Activation happens on insert/update/retract operations on session. So, in your case you should insert or update a fact on session whenever human task is created (for instance with onEntry script) and fire activated rules. To trigger fireAllRules automatically you could use AgendaEventListener registered on the session, example you can find here
HTH
-
4. Re: fireAllRules() in a loop issue
milhaim Feb 6, 2012 10:18 AM (in response to swiderski.maciej)I am already using the AgendaEventListener to automatically fireAllRules, I added a ProcessEventListner to update the working memory, and now it's working fine.
the method to override (more here : https://community.jboss.org/message/608017):
public void afterVariableChanged(ProcessVariableChangedEvent event) {
org.drools.runtime.rule.FactHandle handle = event.getKnowledgeRuntime().getFactHandle( event.getProcessInstance() );
if(handle != null){
event.getKnowledgeRuntime().update( handle, event.getProcessInstance() );
}
}
Many thanks