I have a question about the behavior I'm seeing when I suspend a process while a serviceTask is executing (code in a JavaDelegate).
Here's an example flow:
http://camunda.org/share/#/process/fa6dcbf8-6a0d-4272-b0fe-959ae44efdfa
If you:
1) start this process
2) suspend via Cockpit while serviceTask is running
3) wait til serviceTask finishes executing (will throw stacktrace -- see below)
4) re-activate process instance
I understand that at this point I the process will continue on when the job retry fires (about 5 minutes later). However, in my case, since the serviceTask actually finished executing successfully, and didn't really "fail" (well it only failed in the sense that the instance wasn't active when it completed).
Therefore, I would rather avoid the situation where it retries. I would rather it just retry the "complete" task portion of the code, not the entire
public void execute(final DelegateExecution execution)
body of code (which already ran).
Are there some recommendations and/or best practices about how this can be accomplished? Can the JavaDelegate check (with perhaps retries) whether the process instance is active before falling out of the execute method?
I hope my question makes sense.
Thanks,
Galen
Roman, yes I think I did get an OptimisticLockingException.
In terms of process instance suspension, It seems to me, that if possible, the implementation could:
1) Let all of the currently active/executing tasks "drain out" before committing the suspension of the process instance.
2) Prevent new tasks from being started (prevent the token(s) from moving), but it would let the current tasks complete successfully (without exception). I guess technically this solution would allow for one last token movement only on currently active tasks.
I think the whole purpose of suspension is to prevent further token movement, right? As Rob pointed out, service tasks are not always interruptable, so it seems the best thing to do would be to let them finish, as opposed to do something you know will cause a failure/retry.
I don't know how feasible this would be, especially with non-asynchronous tasks, but it seems like the behavior I would expect as an end-user.
I guess another solution would be to set retries to zero for tasks you know for sure should never run twice.
Rob: Thanks for the tips, those all make sense, and I see how they would minimize, but not entirely eliminate the race conditions. For your third point, a message bus (to hold a de-coupled "service complete" message) and a consume task (instead of a callback) would probably work, even in the face of a suspended process instance. Do have an example of the "interruping boundary event on a transaction which wraps these two tasks"? I'm still trying to understand that concept...
Thanks,
Galen