6 Replies Latest reply on Apr 3, 2008 10:53 AM by estaub

    Dynamic Process Instances

    jimtbds

      After evaluating JBPM and walking through a few use cases I have determined that the inability to quickly modify workflow instances is a problem. In classic workflow there is a workflow definition of which instances are instatiated (sound familiar - like class/object). However, it is often necessary to modify the workflow instances on the fly. For example if you have 5 chapters in which the "first draft" has to be done by technical writers before you proceed to "full document review", then you have 5 tasks in workflow which converge into a "join" in workflow which then go into a single "review entire document" task. Unfortunately, if half way through (as happens in writing) you discover you need 8 chapters, it is difficult to modify the workflow instance. This is because the workflow instance is based on a workflow def which only had 5 tasks. Basically this is a large problem. Am I missing something obvious? How could I do this in JBPM. Seems like we need a sub process that can have an arbitrary number of tasks?

        • 1. Re: Dynamic Process Instances

          In the specific case you talk about, a loop is probably a good design fit - all chapters are similar, presumably.

          In the similar case of a dynamic number of similar parallel activities, a fork can be told to generate as many similar child tokens (like threads) as necessary.

          • 2. Re: Dynamic Process Instances
            jimtbds

            I don't think a loop does the job. I have multiple n authors that can concurrently document m chapters. I would imagine a "create draft" for each chapter. However the number of chapters can change dynamically - eg: we can decide we need more chapters.

            I was looking at the task management chapter in the user doc

            11.2.2. Task instances and graph execution

            And it seemed to suggest multiple taskInstances for a task node:

            public class CreateTasks implements ActionHandler {
            public void execute(ExecutionContext executionContext) throws Exception {
            Token token = executionContext.getToken();
            TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();

            TaskNode taskNode = (TaskNode) executionContext.getNode();
            Task changeNappy = taskNode.getTask("change nappy");

            // now, 2 task instances are created for the same task.
            tmi.createTaskInstance(changeNappy, token);
            tmi.createTaskInstance(changeNappy, token);
            }
            }

            • 3. Re: Dynamic Process Instances

              Ah, ok, so it's parallel, not sequential. Then use the dynamic fork. See http://wiki.jboss.org/wiki/Wiki.jsp?page=ForEachForkActionHandler.

              • 4. Re: Dynamic Process Instances
                jimtbds

                Dynamic Fork looks good, however, new chapters may be needed after the dynamic fork has fired. For example, the dynamic fork fires and there are 10 chapters needed and 10 tasks get created for those tasks. During the authoring of oneof those chapters it is determined that another chapter is needed - how is that introduced?

                As well, you did not comment on the task instance example of the previous post - how do you interpret that code?

                • 5. Re: Dynamic Process Instances
                  kukeltje

                   

                  how is that introduced?
                  Almost identical I would hope, just look up the token that is in the parent node (the fork) and add an additional task


                  • 6. Re: Dynamic Process Instances

                    >> As well, you did not comment on the task instance example of the previous post - how do you interpret that code?

                    Sorry, I don't remember much about the task support - I don't have the time to research it.