I’m trying to use Camunda to manage our internal documents flow , and we need to set a due date for the whole process, not for an individual task. I’ve googled a bit and I found some articles about the timeout task listener, but I don’t know how to use it. This is what I’m trying to do:
In the process start form, add a process_due_date variable to let the user select a date.
Add a “create” task listener Java class and assign it to each of the following tasks. Basically, I want to set the newly created task due date to process_due_date.
Now, add a “timeout” task listener Java class to each task. My idea is that, whenever any task exceed the due date that we set at the beginning, an email is sent to the task owner.
I’ve read some of the articles about the timeout task listener, but I don’t know how to proceed. These are the steps I think I need to take:
Enable Job Executor. I’ve edited the resources/META-INF/processes.xml file and I’ve added the following line: <property name="jobExecutorActivate" value="true" />
Create a Java class to hold the listener code (f.i. TaskTimeoutListener.java)
Use Modeler to add that class to all the tasks.
Is this approach correct? I see that, to define a timeout listener in the Modeler, I must define a Listener Id but I don’t know what to put in here. A different name for each task (f.i. ‘StartTaskTimer’, ‘CheckTaskTimer’, etc? Do I have to define these ids elsewhere?
I suppose that I need to specify the due date in the “Timer Definition” field. This date is set in the process start form, associated to the process start event, so how could I pass it to this timer event?
Please try to initiate the “due_date” by doing execution.setVariable(“due_date”,DATETIME); in the start listener of the "start process " start shape. This should resolve the issue.
Hi, I just tried it and it still doesn’t work. In the start event, I’ve added an ‘start’ task listener with the following code:
public class ProcessStartListener implements TaskListener {
@Override
public void notify(DelegateTask delegateTask) {
DelegateExecution ex = delegateTask.getExecution();
ex.setVariable("due_date", new Date());
}
}
But it seems that the remainder subprocess starts before this ‘start’ listener, because I get the following error:
24-Jan-2020 13:50:32.414 SEVERE [http-nio-8181-exec-826] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: Unknown property used in expression: #{due_date}. Cause: Cannot resolve identifier ‘due_date’
I’m trying another approach that I’ve seen in a forum and I’ll post an update. Thanks!
@ felipRR - Just a observation . I see the class implementing a task listener whch wouldnt be available on the start shape of the BPM Process .Can you cross verify . I have pasted a screenshot for your reference .
Hi! Yes, that worked! I modified the BPM as you suggested and it’s working as expected, the remainder is sent on the date the user selects in the start form.
I’ve been with other projects for a while and I returned to this one today. I realized that, when the remainder subprocess is fired, the main process ends, so the ongoing task disappear from the dashboard. I only want to send an email, without finishing the process. Just for trying, I simplified the remainder subprocess like this:
I’ve added an “start” listener to the event to send the email without the need for a task, but it also finishes the main process flow. Is there anything I can do?