A sequential flow to create a process instance and then a task
What we are doing:
1. We have a task listener configured for a user task which essentially send a notification to start processing some data to an external module.
2. Once the processing is done, the module marks this task as completed.
3. Essentially, our process flow contains all User Tasks configured like above.
What is happening:
1. We create a process instance, and immediately, the first task is initiated - Meaning, the task listener is invoked.
2. By the time process instance is stored in database, we get a request from external module to mark the task as completed. And hence we face ActivitiObjectNotFoundException. Since the process instance along with task id is not yet commited in DB.
Below logs for reference:
1. Made a call to runtimeService.startProcessInstanceById 2. Entering Task Listener 3. Message sent to external module: processId:62549 taskId:62564 4. Exiting Task Listener 5. Created processInstance id: 62549 // Call to startProcessInstanceById completed
Similar behaviour is observed for second task in line. While marking the current task as completed, the next task's listener is called.
What we intend:
1. Made a call to runtimeService.startProcessInstanceById 2. Created process instance with ID: 62549 3. Created Task instance with ID: 62564 4. Entering Task Listener 5. Message sent to external module: processId:62549 taskId:62564 6. Exiting Task Listener 7. Wait till the task is completed by external module and we receive such message from that module.
Is there a way to achieve this scenario without having customizations?
We are using queues to manage the communication. Hence the term message means: message on a particular queue.