Activiti / Camunda change boundary timer with vari

2020-02-26 13:22发布

I got a special question regarding timer boundary events on a user task in Activiti/Camunda:

When starting the process I set the timer duration with a process variable and use expressions in the boundary definition to resolve the variable. The boundary event is defined on a user task.

<bpmn2:timerEventDefinition id="_TimerEventDefinition_11">
        <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression">${hurry}</bpmn2:timeDuration>
      </bpmn2:timerEventDefinition>

In some cases, when the timer is already running it can occur, that the deadline (dueDate) should be extended because the asignee has requested more time. For this purpose i want to change the value of the process variable defining the deadline.

As it happens, the variable is already resolved at the process-start and set to the boundary event.

Any further changes of the variable do not affect the dueDate of the boundary timer because it is stored in the database and is not updated when the value of the variable changes.

I know how to update the dueDate of the job element via the Java API, but i want to provide a generic approach like setting it with changing the value of the variable.

The most common use case for extending the deadline will be when the boundary timer is already running.

Any ideas how to cope with this problem?

Any tips are very apprechiated. Cheers Chris

3条回答
Luminary・发光体
2楼-- · 2020-02-26 13:43

Solution is to have 2 out going sequence flow, one should be from boundary timer on task and another one should be from task it self, as shown in diagram added by @theFriedC. See following image also.enter image description here

Then you can use some exclusive gateway on 2nd sequence flow and reroute that back to same task with a new timer value.

查看更多
我只想做你的唯一
3楼-- · 2020-02-26 13:54

If the timer is running you can change dueDate of the timer by executing a signal. If a assginee requested more time, set new value of hurry and execute the signal. The old timer will be canceled and the new timer will be created with new due date.

runtimeService.setVariable(execution.getId(), "hurry", newDueDate);
runtimeService.signalEventReceived(signalName, execution.getId());

Process with signal

查看更多
做个烂人
4楼-- · 2020-02-26 13:56

After some time of thinking I came up with a workaround like that:

enter image description here

I start the process with two variables. "hurry" is evaluated for the boundary timer. And "extendDeadline" is initialized with false. If the timer triggers and the process advances to the exclusive gateway, the value of "extendDeadline" is evaluated.

If a user has changed the value of "extendDeadline" to true during the the timer was running the process returns to the user task again where the boundary timer is set to the value of "hurry".

If the "extendDeadline" is still set to false, the process can proceed.

查看更多
登录 后发表回答