I have an application with lot of modules, one of them is the activiti BPM engine. I use elasticsearch (ES) as the datastore. There is also a web application, which serves as a trigger to executing the processes and providing data. Every process has its instance in the ES and the available list of tasks (the mapping to the activiti task instances) is also stored in the process metadata. I've been playing around with synchronization of the tasks list between the BPM engine and the datastore and I am still not satisfied. What I am doing is following - the workflow of the application:
Create a new case (which is modeled by the BPMN process) in the ES and get the ID.
Start the process in the activiti engine and associating it with the ID from step 1 using the businessKey parameter.
Update the tasks list in the ES using a TaskListener with an expression (which calls a method on a java class) on the createEvent of every task.
The problems are following. First of all I would need to define such a TaskListener on every task in the process (there are about 150 complex processes). Second problem is, that the when the TaskListener is called and query the engine for the tasks I am not getting the just created task in there (I suppose this is because of the listener being called before the task entity is created, or the transaction committed).
So the question is, what is the best way to configure some kind of a global listener for the engine which notifies me every time when there is something changed with any process from the deployment so I can query the tasks list and update the ES?
This is indeed possible. But the problem still is that the transaction most probably has not been completed yet. This way you can obtain the TASK entity, but when you in this moment query the BPM Runtime to get the list of tasks, it would not be present in the list.