Programmatic task execution reopens the task
matrixpooh Nov 9, 2009 11:29 AMMy sub-process definition consists of 3 sequential task nodes: start, task 1, task2, task3, end. At some point in the main process, I instantiate the sub-process. Later on, I retrieve the sub-process by id and trigger execution of the first task. The task successfully executes and
* falls down to initializeTaskVariables() of the task 2.
* commits task 1
* calls initializeTaskVariables() of task 1
* completes the token execution.
At the end of the run, the subprocess has 2 active tasks: a brand new task 1 and task 2. Repeating the call twice, I end up with all 3 tasks being successfully processed and 3 new tasks being created and pending in users' queue.
I observe the same problem running a much simpler case: a process definiton with 1 split, 2 tasks, 1 join. Seems that any programmatic execution of a task causes its execution followed by immediate instantiation of the same task.
I would appreciate if you could point out what I'm doing wrong
Here's the code snippet from main process instance:
final ProcessInstance subProcessInstance = ctx.getJbpmContext() .getProcessInstanceForUpdate(subprocessInstanceId); ..... ExecutionContext subprocessContext = new ExecutionContext(subProcessInstance.getRootToken()); subProcessInstance.getRootToken().getNode().execute(subprocessContext);
This is debug output:
11:24:20,078 WARN |main|: [ProxyWarnLog:narrowProxy:615] Narrowing proxy to class org.jbpm.graph.node.TaskNode - this operation breaks ==
11:24:20,093 DEBUG|main|: [CompleteAnalystTasksController:initializeTaskVariables:42] -------------current node::Perform Analyst task 1
11:24:20,093 DEBUG|main|: [GraphElement:fireEvent:179] event 'task-end' on Task(Perform Analyst task 1) for Token(/)
11:24:20,093 DEBUG|main|: [CompleteAnalystTasksController:submitTaskVariables:52] -------------current node::Perform Analyst task 1
........
11:24:20,968 WARN |main|: [ProxyWarnLog:narrowProxy:615] Narrowing proxy to class org.jbpm.graph.node.TaskNode - this operation breaks ==
11:24:20,984 DEBUG|main|: [CompleteAnalystTasksController:initializeTaskVariables:42] -------------current node::Perform Analyst task 2
11:24:20,984 DEBUG|main|: [GraphElement:fireEvent:179] event 'task-create' on Task(Perform Analyst task 2) for Token(/)
11:24:21,000 DEBUG|main|: [TaskInstance:setActorId:258] assigning task 'Perform Analyst task 2' to 'analyst'
11:24:21,000 DEBUG|main|: [GraphElement:fireEvent:179] event 'task-assign' on Task(Perform Analyst task 2) for Token(/)
11:24:21,000 DEBUG|main|: [GraphElement:fireEvent:179] event 'after-signal' on TaskNode(Perform Task 1) for Token(/)
11:24:21,000 DEBUG|main|: [GraphElement:fireEvent:179] event 'task-create' on Task(Perform Analyst task 1) for Token(/)
11:24:21,015 DEBUG|main|: [TaskInstance:setActorId:258] assigning task 'Perform Analyst task 1' to 'analyst'
11:24:21,015 DEBUG|main|: [GraphElement:fireEvent:179] event 'task-assign' on Task(Perform Analyst task 1) for Token(/)
11:24:21,015 DEBUG|main|: [RecordCriterionChangeHandler:execute:66] ------------------Subprocess current Node After Call::TaskNode(Perform Task 2)