Something like this might work
public void notify(DelegateExecution execution) {
ManagementService managementService = ..;
TaskService taskService = ..;
Job timerJob = managementService.createJobQuery().processInstanceId(execution.getProcessInstanceId()).activityId(execution.getCurrentActivityId()).singleResult();
Task task = taskService.createTaskQuery().executionId(timerJob.getExecutionId()).singleResult();
}
Note that both job
and task
can be null
if the task has been completed/cancelled in the meantime.
Cheers,
Thorben
Edit: The job query only works if this task is active only once per process instance. I don’t think there is a good way to get this in the general case, as there is no connection between the execution executing the execution listener and the execution representing the user task activity instance.