2 Replies Latest reply on Jan 13, 2012 3:24 AM by eaa

    can i use rule task in embedded sub-process?

    hardawaycg

      i want to keep all my java code in drl file,so i dont want to use script task but rule task ,i can put those java code in RHS in rule

      when i place a script task in embedded sub-process and write java code in action,it works.but when i replace the script task as a rule task,it doesn't work,why?

       

       

      未命名.jpg

        • 1. Re: can i use rule task in embedded sub-process?
          hardawaycg

          sorry,after kinds of test,i found this is not because of embedded sub-process,but signal event.

           

          rule task doesn't work on a flow file if these is signal event,this is my test case:

           

          scene1: just like below,it works:

          未命名.jpg

          with java code like this,the console print run,it works.

          ProcessInstance process = ksession.startProcess("test2Flow");

                                        ksession.fireAllRules();

                                        ksession.signalEvent("event1", null,process.getId());

          scene2:

          1、replace the script task with a rule task,and set ruleflowgroup as sub1

          22名.jpg

          2、create a drl file and write a rule name "rule1":

          rule "rule1"

                    ruleflow-group "sub1"

              when

                 

              then

                  System.out.println("sub1");

          end

          3、add the drl resource on java code ,then run code like before.

          the result is console print nothing ? why ?

          • 2. Re: can i use rule task in embedded sub-process?
            eaa

            According to the information you have exposed, I can state this: After you call ksession.signalEven(), the process continues its execution and reaches the Rule Task node. At this point, the rule is activated (check the output log to check this) and the process execution stops returning to the line after ksession.signalEvent(). At this point you need to tell the session to execute all activated rules: ksession.fireAllRules(). When fireAllRules() gets executed, the process execution continues and reaches the end node.