-
1. Re: How to execute business rule from specific rules node
swiderski.maciej Jul 9, 2014 1:39 AM (in response to cgwang1992)business rule task will fire all rules from defined ruleflow group if they are activated - activation means there are matching facts in ksession so rules can execute. What is most likely happening in your case is that you activate rules after your process has been completed because you insert facts after starting process. So if you change the order of method invocation on ksession to be like this:
- ksession.insert
- ksession.startProcess
then your rules will be fired from within process instance and no need to have explicit call to ksession.fireAllRules
In addition, declaration of inputs/outputs on business rule task is not mandatory and is only used to insert/delete facts before/after executing business rule task node.
HTH
-
2. Re: How to execute business rule from specific rules node
cgwang1992 Jul 9, 2014 12:52 PM (in response to swiderski.maciej)Thanks for your reply Maciej!
I have rules in my .drl file that corresponds to the objects that I inserted with ksession.insert. For example:
ksession.insert(Person); where Person has the variable age.
rule "age less than 10"
when
$age: (Person > 10)
then
System.out.println("Greater than 10");
end
Is this what you mean by activated? As in the facts of the rules are matching the object? I reorganized the insert and startprocess commands but now instead of executing the rules the ruletask node is skipped completely...
Thanks!