Hi there,
We are building SpringbootApplication using org.flowable:flowable-spring-boot-starter-process-rest:6.4.1"
We created *.bpmn20.xml with multiple asynch Service Tasks .
Now we want to have a capability to Cancel or Pause the execution of a process on demand.
We have also deployed flowable-*.war files in the tomcat . After we trigger Springboot Application through postman and go to flowable-admin war application , Process Engine --Definitions–>Process Instances , we can see one of the process instance is active . But we are not able to see what specific task it is executing at that moment (the Tasks tab is empty) or any handle to Cancel or pause the flow.
What is the best way of doing that ? Can we achieve that through flowable-admin application? Also is there possibility of building end points in Springboot for these handles (cancel/pause/restart etc)
There are Java APIs and REST endpoints to do most if not all of what you are asking for. Look in the runtime service for most of these behaviors on the Java API side. The flowable-rest app contains the swagger docs, I usually keep and instance around in a docker container for reference like so:
docker run --name flowable-rest-docs -p 8888:8080 flowable/flowable-rest
Because that command exposes the container at port 8888 on the localhost you can then go to http://localhost:8888/flowable-rest/docs/ and see the docs.
The same REST endpoints that flowable-rest uses are available by including the flowable-spring-boot-starter-rest dependency. If you look at the source of the rest app, you’ll see its mostly just the starter plus security configuration and swagger documentation. The flowable-admin app uses these endpoints to do all of it’s work, but I don’t think suspending/activating a process is one of its features.
A note on suspending a task: Suspending a running process can get complicated. It does not interrupt running code, like service tasks, but it does mark the process as suspended. When the service task returns, it will see that the process has been updated and throw and optimistic lock exception. When the exception gets thrown the transaction will get rolled back to the previous wait state.
{ “timestamp”: “2020-02-15T17:47:27.597+0000”, “status”: 500, “error”: “Internal Server Error”, “message”: “\n### Error updating database. Cause: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource\n\n### The error may involve org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.updateExecution-Inline\n### The error occurred while setting parameters\n### SQL: update ACT_RU_EXECUTION SET REV_ = ?, SUSPENSION_STATE_ = ? where ID_ = ? and REV_ = ?\n### Cause: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource\n”, “path”: “/flow-orchestrator/process/suspend-process” }
I have 20+ service tasks. Earlier I had made first task Async and suspension used to work fine. Lately , I have made all the tasks Async . Not sure if that is contributing to the exception in some way.
How do I mitigate the deadlock scenario ? Appreciate the suggestion.
Multiple async tasks in parallel might cause issues if they are short lived and finish at nearly the same time. There was a post a while back with a similar error:
Thanks wwitt.
I am thinking if we could introduce some kind of wait window after every few service tasks , the suspension/cancellation request may get hold of the resources and hence avoid deadlock scenario.
Some thing like "do nothing for few seconds and release all the locks " window.
Could you advice , how best I can introduce such wait window/state during the flow .
@wwitt,
Just to update, I upgraded to version 6.5.0 . Now instead of getting “deadlock” exception, I am getting
“Execution[ id ‘b702602f-58e6-11ea-baeb-0050568e1cce’ ] - activity ‘XXXXXX’ - parent ‘b701eaf6-58e6-11ea-baeb-0050568e1cce’ was updated by another transaction concurrently”
I have 20 + asych service tasks which takes 2+ minutes to complete end to end . If I trigger suspension requests mutiple times during the 2 minutes, I see same error message , only the activity (service Task name) changes .
This leads me to believe , somehow the running process is not releasing the control to external request seeking suspension of the process.
Also I don’t need it to suspend right away. I don’t mind if the suspension request can wait till the current transaction is finished and then suspend the execution .
Thoughts ?
When you suspend a process it marks the processes as suspended, it will not interrupt service tasks and jobs that are already in flight. The executing tasks complete they will attempt to update the process and see that it has been changed. This will result in an error, causing the transaction to roll back.
You can either refrain from suspending processes while service tasks are running or accept that errors will occur and handle them appropriately.
So you mean the deadlock exception that I have been observing is infact “Optimistic Lock Exception” which should rollback the transaction to previous wait state. But then when I try to resume it using