9 Replies Latest reply on Jan 17, 2011 1:53 PM by salaboy21

    Understanding Human Task call

    odelyaholiday

      Hi!

       

      I created the BPMN file. The first item is human task. I set on the human task actorId Phil,Joe. My process needs to start with parameters of requestData.

       

      I started the process like this:

       

      // 2. get the session to start a process.
        ManagementBean managementBean = (ManagementBean) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("ManagementBean");
        StatefulKnowledgeSession ksession = managementBean.getKsession();
      
        // 3. Starting the process
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("requestData", prgoramData);
        ProcessInstance pI = ksession.startProcess("MyProcess", parameters);
      
      

       

      Now, I expect the process to reach the human task and display my On Entry Actions.

       

      Intead I get an exception "org.drools.WorkItemHandlerNotFoundException: Could not find work item handler for Human Task"

       

      Do I need to start it somewhere?

        • 1. Understanding Human Task call
          salaboy21

          Hi there,

          In order to work with Human Tasks/ User Tasks you need to register a WorkItemHandler that knows what to do when a User task is reached in your processes. You can do that with:

           

          ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new ServiceTaskHandler());

           

          Of course you also need to start up the Task Service Server.

          Greetings.

          • 2. Understanding Human Task call
            odelyaholiday

            Is Human Task a reserved word? why shouldn't it start automatically when the workflow reached HumaTask element?

             

            As well, when I want to mention that I complete the task - how do I do it?

             

            I found that there are start and complete for human task . When shall I use them?

            • 3. Understanding Human Task call
              salaboy21

              Hmm.. you sound confused..

              When you model a BPMN2 process with an User Task, the xml generated creates a tag with an attribute containing the "Human Task" id. This id is used to bind a service that will be in charge of handling the life cycle of a human task (with the line of code that I pasted before). The reason why you need to start the TaskServer by hand is because it's an independant service that you can change if you want and provide a different implementations that suits your needs.

              You last sentence ("I found that there are start and complete for human task . When shall I use them?") mention the TaskClient that is in charge of interacting with human tasks that are already created by your process in the Task Server. Using the client you can Start a task (meaning that you will start working on the task) and complete a task (meaning that you end the task).

              The interaction between these components can be is described in the following image:

              http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-flow/html/images/Chapter-HumanTasks/component-distribution.png

              Try reading the following chapter of the Drools Flow documentation for more information:

              http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-flow/html/ch.Human_Tasks.html

               

              Greetings.

              • 4. Understanding Human Task call
                odelyaholiday

                Thanks

                 

                So I understand that HumanTask has to be the id of that human task in the BPMN file? Since I couldn't find this name in Emergency BPMN diagram, while the EmergencyService has

                 

                ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));

                • 5. Understanding Human Task call
                  salaboy21

                  You can register different types of HumanTaskHandlers. In the emergency application I've used the CommandBasedWSHumanTaskHandler because it gives you some extra features for different environments. You are true, in my application it didn't have the "Human Task" string in my BPMN file, but that's because I was using an old schema where you need it.

                  Right now you need to register the "Human Task" workitemHandler with one of the TaskHandlers implementation in order to work.

                  Sorry for the confusion.

                  • 6. Understanding Human Task call
                    odelyaholiday

                    I am sorry to bother again but in the human task element of the BPMN file there is no TaskName attribute !

                     

                    It only has Name attribute!

                     

                    So how do I connect from it to the handler?

                    • 7. Understanding Human Task call
                      salaboy21

                      If you are using the SNAPSHOT you don't need to worry about it. The exception that you get:

                      "org.drools.WorkItemHandlerNotFoundException: Could not find work item handler for Human Task"

                      Can be solved just registering the "Human Task" WorkItem Handler

                      Did you do something like:

                      ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));?

                      What is the error now?

                      • 8. Understanding Human Task call
                        odelyaholiday

                        I changed it to ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));

                         

                        and now it works!! thanks !

                        • 9. Understanding Human Task call
                          salaboy21

                          Great! keep us posted if you have troubles!