Activiti / Camunda change boundary timer with variable

穿精又带淫゛_ 提交于 2019-12-18 13:37:52

问题


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


回答1:


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());




回答2:


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

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.




回答3:


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.

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



来源:https://stackoverflow.com/questions/30170191/activiti-camunda-change-boundary-timer-with-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!