Hi,
We are trying to create a standalone application in Java using Activiti APIs. We have been trying to add timer to execute a certain flow after the given time-out. But this is not working as per the expectation. Below is the sample code.
<java>
public static void main (String[] args) {
ProcessEngine processEngine=ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment().addClasspathResource("diagrams/demo2.bpmn").deploy();
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance pi = runtimeService.startProcessInstanceByKey("escalationExample");
// There should be one task, with a timer : first line support
TaskService taskService = processEngine.getTaskService();
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
System.out.println("First line support = " + task.getName());
// Manually execute the job
ManagementService managementService = processEngine.getManagementService();
Job timer = managementService.createJobQuery().singleResult();
managementService.executeJob(timer.getId());
// The timer has fired, and the second task (secondlinesupport) now exists
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
System.out.println("Handle escalated issue = " + task.getName());
}
We are expecting "escalated issue task" i.e. "secondlinessupport" should be executed after the time-out of 5 min. What is wrong with the code?
Is there any way to handle the timer event and how?