9 Replies Latest reply on Mar 9, 2009 9:12 PM by Ronald van Kuijk

    Tasks need to done by multiple users

    Naeem Jamil Newbie

      How we can do in the jbpm engine to perform task by all multiple users.

      Currently I am using pooled-user attribute of assign as given below.

      <assignment pooled-actors="a, b, c">

      but from the jbpm-console it is not possible to assign this task to all the users ( a, b ,c ) at a time. Secondly if assigned user will start it and finished it. It will be ended.

      How we can do this, when we want to perform a task from multiple users?

        • 2. Re: Tasks need to done by multiple users
          Brad Davis Novice

          In theory, another option would be to have the task node have create-task to false. Then have an action handler in the task note to create many task instances, populating each within a different actorId.

          • 3. Re: Tasks need to done by multiple users
            Ronald van Kuijk Master

            you could, but 'n out of m' or any other comparable exit strategy will be more difficult, but you can.

            • 4. Re: Tasks need to done by multiple users
              Brad Davis Novice

              @Ronald,
              Just so I can think about the difference in approaches, what are your thoughts on why it would be more difficult to do certain exit strategies with my suggested dynamic task-instance approach?

              I guess the join would make sure everyone completed before leaving the fork-task-join block, but doesn't signal="last" on the task-node accomplish the same thing? Additionally, doesn't using the signal= on the task node give more flexibility than a join would, which would fix the user to a pattern of waiting for everyone to complete before moving forward?

              The last point of my implementation is that the graph would not need to change with the dynamic task-instances since it would be an action attached to the task node.

              But then again, I haven't tried to implement this myself. So, I am wondering if there is a technical hurdle here, or what your thoughts are for why it would be more difficult.

              • 5. Re: Tasks need to done by multiple users
                Ronald van Kuijk Master

                Brad,

                It's not the signal last or first it's the in-between that is difficult. Just like with a custom fork, you can have a custom join which gives you all the flexibility you need. Even use businessrules in there e.g. If a manager approves it is already enough, otherwise 2 employees need to approve. Or if the amount is above a certain value the manager has to approve in addition to two employees. You can also model some of these in the process (as I would do since it is part of the process)

                • 6. Re: Tasks need to done by multiple users
                  Brad Davis Novice

                  But couldn't that more complex logic also be coded into the event on the task-end? Just playing devil's advocate.

                  The custom join does add a lot of flexibility, so I know what you mean there.

                  • 7. Re: Tasks need to done by multiple users
                    Ronald van Kuijk Master

                    not sure if you can prevent the tasknode from fully ending or explicitly make it leave the node. There are some limitations build in the task to make sure it behaves as expected.

                    Another reason is that when putting to much process-logic into actions, it becomes invisible in the process image

                    • 8. Re: Tasks need to done by multiple users
                      Brad Davis Novice

                      I just tried this by the way. It works great for cases where you want a number of tasks created. But, as Ronald suggested, more complicated cases require the join pattern. In such cases, a lock token exception is thrown; for example, if I have an event on the end of the task instance to kill another task in the same node, an exception will occur.

                      Like I said though, if you just simply want to generate a number of tasks to be created, I think this works great. Within an action handler, you would have:


                       Token token = executionContext.getToken();
                       TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
                      
                       TaskNode taskNode = (TaskNode) executionContext.getNode();
                      
                       Task example = taskNode.getTask("Example");
                      
                       tmi.createTaskInstance(validateDateTask, token);
                       //Generate some tasks on the fly.
                       for(int i=0; i<3; i++)
                       {
                       TaskInstance instance = tmi.createTaskInstance(example, token);
                       instance.setVariableLocally("ExampleVar", "AAA"+i);
                       instance.setVariableLocally("Example2Var", new Date());
                       }
                      


                      Process definition:
                       <task-node name="task-node1" create-tasks="false" signal="last">
                       <event type="node-enter">
                       <action class="com.example.DynamicGenerateActionHandler"></action>
                       </event>
                       <transition to="end-state1"></transition>
                       <task name="Example">
                       <controller>
                       <variable name="ExampleVar" access="read"></variable>
                       </controller>
                       </task>
                       </task-node>
                      


                      • 9. Re: Tasks need to done by multiple users
                        Ronald van Kuijk Master

                        Not supported and behaviour undefined:

                        You can unlock the token in your code!!