Hide Forgot
Created attachment 838324 [details] the process definition with a rule task Description of problem: I have a process definition with a single rule task and a script task after. In the rule task I add items into a global variable "executed". The script task gets the global variable, prints its content and set it to a process variable. What happens next is quite strange and the output can explain it best. Before RuleTask -- this is the first script task before the rule task firstRule secondRule After RuleTask -- this is the second script task after the rule task [firstRule, secondRule] -- as you can see, the "executed" variable contains only 2 items thirdRule -- the rule task is still evaluating thirdRule2 thirdRule3 thirdRule4 thirdRule5 firstRule -- and here it starts the rule evaluation once again (when I don't use the "expected" variable, this second evaluation of rules will not be started) secondRule thirdRule thirdRule2 thirdRule3 thirdRule4 thirdRule5 It's interesting that the process variable "results" is updated by the rules and when I get the variable on the client side to check it, it contains right number of items (7). The behaviour in Business central is much more strange. The rule task is not evaluated at all and after I start a process instance, the state of this instance is COMPLETED though I did not fired the rules. The difference is when I don't use the "expected" variable in the last script task; then the rules are evaluated just after I call fireAllRules via remote API: 13:15:19,911 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) Before RuleTask 13:15:19,918 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) firstRule 13:15:19,921 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) secondRule 13:15:19,925 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) After RuleTask 13:15:19,927 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) [firstRule, secondRule] 13:15:19,959 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) thirdRule 13:15:19,961 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) thirdRule2 13:15:19,962 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) thirdRule3 13:15:19,963 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) thirdRule4 13:15:19,963 INFO [stdout] (Thread-2 (HornetQ-client-global-threads-227014132)) thirdRule5 Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
Created attachment 838325 [details] RuleTask.drl
Ivo, just executed that on kie-wb and I believe it works as expected. Let me explain: 1. there are only three rules defined with ruleflow-group attribute matching the one used in business rule task. 2. first two rules that has no conditions on them will be fired as part of the rule flow group of the business rule task, third one (defined as last rule) won't be fired as it's condition is not met 3. even though second one will trigger another rule to fire but the other rules are not part of the rule flow group of the business rule task thus it does not wait for it any more (rule flow group activation is over) 4. since you move the reference of the global into process variable it will contain all the entries as they will be filled in once process completes. If you would clean the global once process complete you would see it contains only values inserted after process is completed - no two first entries Please note that on kie-wb/business-cental there is no need to fireAllRules when rules are executed as part of the process, there is already a listener that does that for you
1-4 Oh, of course you are right, it makes sense now, thank you :) and the fireAllRules is really always called, so we can close this bug ... with remote API I got that the process instance is ACTIVE and another time that it's COMPLETED when I changed the process definition a little. I still plan to look at this but probably we cannot do nothing with it.