1

I have a problem with integrating business rules in my BPMN2 process model. So my process looks like this enter image description here

The drl file contains only one rule:

 import com.sample.ProcessTest.User;

 rule "AgeCheck"
 ruleflow-group "AgeRules"

 when
     u:User (u.getAge()<17)
 then
     u.setName("Denied");
 end

My problem is that I have two parameter Age, Name, and if I am not using rules I can pass them on gateways, script processes, but when I am using a business rule task it stops at this node.

I am starting the process from eclipse,

    ksession.startProcess("_New.Process2", params);
    System.out.println("Process started ...");
    ksession.fireAllRules();

I added the resources,

    kbuilder.add(ResourceFactory.newClassPathResource("Process2.bpmn2"), ResourceType.BPMN2);
    kbuilder.add(ResourceFactory.newClassPathResource("AgeRules.drl"), ResourceType.DRL);

In the properties of RuleChecker node the rouleflow group is set to AgeRules and I have the following outcome when I am trying to run my project:

    BEFORE PROCESS NODE TRIGGERED node:RuleChecker[id=5]        process:Process2[id=_New.Process2]
    BEFORE RULEFLOW GROUP ACTIVATED group:AgeRules[size=0]
    AFTER RULEFLOW GROUP ACTIVATED group:AgeRules[size=0]
    AFTER PROCESS NODE TRIGGERED node:RuleChecker[id=5] process:Process2[id=_New.Process2]
    AFTER PROCESS NODE TRIGGERED node:InputUser [id=2] process:Process2[id=_New.Process2]

I don't know what is the problem exactly because the process stops at the rulechecker. If anybody can help me with this please explain me what is the problem

Kind regards, Hunor-Attila Kerekes

1 Answers1

0

It is normal that the engine stops at the RuleChecker node, as shown in the audit log. It will simply wait until the rules that were activated as part of the ruleflow group have fired. In your code fragment, you seem to be calling fireAllRules(), have you registered an agenda listener as well, and do you see any rules firing? Or do you see the activation or deactivation of rules? It might be worth looking at the debug views in Eclipse immediate before calling fireAllRules to see if there are any rules activated and firing.

Kris Verlaenen
  • 2,918
  • 1
  • 15
  • 5
  • Thank you very much for your answer, your questions lead me to find the solution faster by adding this code part to my example: 'new Thread(new Runnable() { public void run() { ksession.fireUntilHalt(); } }).start();' ksession.startProcess("_New.Process2", params);' – Kerekes Hunor-Attila Mar 19 '12 at 01:10