cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow failure test

testn
Champ in-the-making
Champ in-the-making
I saw that there are multiple examples of unit tests that test the workflow by waiting until the process count is 0. However, the workflow can stop due to several reasons including failure. I wonder what the right way to monitor and handle workflow execution failure?
7 REPLIES 7

jbarrez
Star Contributor
Star Contributor
In Activiti, when an exception happens, the process instance is rolled back to the previous state in the database.
So you really, you need to catch the exception in the code calling Activiti.
The only place where this doesn't work like that is in jobs: there the exception is stored in the job row in case of failure.

testn
Champ in-the-making
Champ in-the-making
Thanks for the reply. So there is no good way to inspect the failure and error? I use REST API to kick off  asynchronous workflow and would like to wait until the workflow completes or fails. If it fails, I would like to know why.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Each failed job has org.activiti.engine.runtime.Job#getExceptionMessage.

Regards
Martin

testn
Champ in-the-making
Champ in-the-making
Thanks. It seems to be like that. I do have a few more questions though:
1. Can I expect that the workflow will be in "suspended" state when the job failed?
2. It looks like it only keeps the exception message detail but not the type of the exception itself?

jbarrez
Star Contributor
Star Contributor
1. Depends on your definition of 'suspended'. The process definition will not move past the job … but other parts of the process definition could still be moving on (in case you have parallel gateways and such).

2. The stacktrace is also saved in the database and you should be able to get it via the Job.

testn
Champ in-the-making
Champ in-the-making
Hi,

Correct me if i'm wrong but
1. It looks like when the job retry count is set to 0, it will not be picked up by the job executor anymore. So it's not possible to get a trigger when the job actually fails.
2. The stack trace seems to be stored as blob but JobCollectionResource and JobResource do not return them in the REST API.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

1) you can reset retry count again by ManagementService
2) you can extend rest service in that case.

Regards
Martin