First of all, hi all there, I am new on this community.
Second, sorry for my bad English.
I hope someone can help me with this problem (sorry if this is a silly question).
It is related with:
I have a concurrence problem. A user manually ends a pending task instance (TaskInstance.end()). The following activities until next "wait state" are long running (several minutes). We would like the user to synchronously wait until end of execution.
As the user is working at a web environment he can, at any moment, look for task instances to end (JbpmContext.getTaskMgmtSession().findTaskInstances(actorId) at another thread). If the user perform this query while a the previous activities are not finished, he finds the same task instance as before an is able to end it again. This leads to a "StaleObjectStateException" on the token in one (or both) of the threads with unpredictable results.
I understand the suggestion on the related discussion, any long time activities can be executed asynchronously in order to avoid this problem. But due to our needs (the user should be able to perform all activities on the process instance synchronously) this is not the desired solution.
¿Is there any way to force jBpm to flush database operations when "save" is called and not wait until the context is closed?
For example, ¿could be valid calling on "task-end" event?:
Or for example, ¿modifing the hibernate session flush mode could be a valid solution? ¿Does it have undesired consequences?
This could help us to avoid the concurrence problem.
Many thanks in advance.
Finally, we have enabled a flag at the cache in order to lock task instances that are in process of being ended.