Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activiti / Camunda change boundary timer with variable

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

like image 615
theFriedC Avatar asked May 11 '15 14:05

theFriedC


2 Answers

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.

like image 165
theFriedC Avatar answered Sep 22 '22 13:09

theFriedC


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

like image 45
fersmi Avatar answered Sep 22 '22 13:09

fersmi