3 Replies Latest reply on Jun 20, 2011 3:16 AM by leon_

    how to fire rules after human task!!!

    houxiaojun

      Here is my process:

      未命名3.jpg

      In the process above,SelectResult is a rule task,i do not know to fire the rules in it after the human tasks ealier.By the way,if the rules can only be fired by "ksession.fireAllRules()" when the current node is a rule task?In the process above i use a script task before the rule task to fire the rule like this:

      未命名2.jpg

      but i can not see the result designed in the rule file:

       

      package com.sample;

      import com.model.Approve;

      import org.drools.runtime.process.WorkflowProcessInstance;

      rule "Request Passed"

          ruleflow-group "select_result"

          when

              $process: WorkflowProcessInstance()

              Approve(result == "pass") from $process.getVariable("approve1")and

              Approve(result == "pass") from $process.getVariable("approve2")

          then

              System.out.println("Your request has passed!");

             

      end

       

      rule "Request Failed"

          ruleflow-group "select_result"

          when

              $process: WorkflowProcessInstance()

              Approve(result == "fail") from $process.getVariable("approve1")or

              Approve(result == "fail") from $process.getVariable("approve2")

          then

              System.out.println("Your request has failed!");

             

      end

       

      The variable request,approve1、approve2 has been defined。Can anybody knows the answer of the problem,hope you can help us who have the same problem!!!

        • 1. Re: how to fire rules after human task!!!
          eaa

          You can use ksession.fireUntilHalt() before you start your process. Something like this:

           

          new Thread(new Runnable() {
                      public void run() {
                          ksession.fireUntilHalt();
                      }
                  }).start();
          
          ksession.startProcess("processId");
          

           

          fireUntilHalt() will fire whenever a rule gets activated.

          • 2. Re: how to fire rules after human task!!!
            houxiaojun

            Thank you very much for your answer.My problem has been solved successfullly.But now i have another one,sometimes when i start a process,the database has the saved the related task successfully.But when i complete the task through the human task view,in the console,information will be printed just like this:

            [2011:06:158 15:06:580:debug] Message receieved on client : AddTaskResponse

            [2011:06:158 15:06:581:debug] Arguments : [5]

            [2011:06:158 15:06:743:debug] Message receieved on client : EventTriggerResponse

            [2011:06:158 15:06:743:debug] Arguments : [org.jbpm.task.event.EventPayload@98bbf6]

            Task completed 5

            [2011:06:158 15:06:745:debug] Message receieved on client : EventTriggerResponse

            [2011:06:158 15:06:745:debug] Arguments : [org.jbpm.task.event.EventPayload@147e668]

            [2011:06:158 15:06:745:debug] Message receieved on client : EventTriggerResponse

            [2011:06:158 15:06:746:debug] Arguments : [org.jbpm.task.event.EventPayload@167c5e3]

            [2011:06:158 15:06:747:debug] Message receieved on client : EventTriggerResponse

            [2011:06:158 15:06:750:debug] Arguments : [org.jbpm.task.event.EventPayload@1f0cf51]

            Task completed 5

            [2011:06:158 15:06:751:debug] Message receieved on client : EventTriggerResponse

            [2011:06:158 15:06:751:debug] Arguments : [org.jbpm.task.event.EventPayload@c9b196]

            Task completed 5

            [2011:06:158 15:06:805:debug] Message receieved on client : GetTaskResponse

            [2011:06:158 15:06:805:debug] Arguments : [javax.persistence.EntityNotFoundException: No Task with ID 5 was found!]

            [2011:06:158 15:06:806:debug] Message receieved on client : GetTaskResponse

            [2011:06:158 15:06:806:debug] Arguments : [javax.persistence.EntityNotFoundException: No Task with ID 5 was found!]

            [2011:06:158 15:06:807:debug] Message receieved on client : GetTaskResponse

            [2011:06:158 15:06:807:debug] Arguments : [javax.persistence.EntityNotFoundException: No Task with ID 5 was found!]

             

            By the way,the task with id 5 shows completed in the database.Can you help me with this?

            • 3. Re: how to fire rules after human task!!!
              leon_

              Check your BPMN proces in eclipse and see if the ID's of the components are all set right. In particular look if the human task that succeeds your rule-task is task 5. Otherwise rename it :-)