Best practice for Task Escalation and special problem with Multi Instance Tasks


#1

My main problem is how to model and implement an escalation on a multi instance task. I want to send a mail to all candidate users to remind them to finish the task. How can i identify the timed out task even if more than one instances of the multi instance task time out.

But I also have a general question: what is the best practice to model such an escalation.

As a discussion base i created the following bpmn:

  • Task1: My first approach was to implement the mailsending in the listener of Timer1. The code to get the task was the following:

    final Job timerJob = this.processEngine.getManagementService().createJobQuery().processInstanceId(execution.getProcessInstanceId()).activityId(execution.getCurrentActivityId()).singleResult();
    final Task taskTimedOut =
    this.processEngine.getTaskService().createTaskQuery().executionId(timerJob.getExecutionId()).singleResult();

    In case of a normal single task this is working, as there is only one timer executed per timed out taskdefinition.

  • Task 2: Here the code to send the mail is tranfered to the servicetask “Send Reminder Mail 1”. The Taskid still is evaluated in the listener of Timer2 (like in Task1). my question here: what is the best way to transfer the TaskId from the listener to the serviceTask?

  • Task 3: Here the code to send the mail is running in the servicetask “Send Reminder Mail 2” in the Event SubProcess. What is the best way to forward the TaskId here?

  • Task 4: Here the problem is, how to evaluate the TaskId to the corresponding Instance of the DelegateExecution. The code from Task 1 to find the timerJob does not work then there are is fired more than one TimerInstance at the same Time. Then don´t known, how to find the timerJob belonging to the DelegateExecution. Then here´s the same question with the forwarding of the taskid to the subProcess like in Task 3.

I would prefer to use the variant with the escalation events, as for me it is the most elegant way to do this.


#2

I am also facing the same issue. Any solution?