cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Error Handling

c_arunrathnakum
Champ in-the-making
Champ in-the-making
Hi All,
   I ve a process UserTask1–>ServiceTask1–>ServiceTask2–>UserTask2.
   
   Presently if an exception has occured in ServiceTask2, the process is still there in UserTask1(was found in act_ru_task table)
   But my requirement is that, if there is an exception in ServiceTask2, what ever i ve done in serviceTask1, has to be rolled back and also the process instance has to be removed.
   [(I ve done this by manually catching the exception in catch block,  reverted what i ve done in ServiceTask1 and used runtimeService.delete(taskId) to delete the instance]
   
   Is there any thing i can do to achieve this in workflow design itself?
3 REPLIES 3

ronnybr
Champ in-the-making
Champ in-the-making
It sounds to me like you should use a transaction subprocess: http://www.activiti.org/userguide/index.html#bpmnTransactionSubprocess
Compensations and transactions are some of the more difficult things in BPMN, but they seem to me like the solution to your problem.

c_arunrathnakum
Champ in-the-making
Champ in-the-making
Thank you… But what if my serviceTask1 executes calls that are synchronous which is not part of the transaction?

This is where my problem is,.

The logic for rollback is written in a seperate service task which should be executed only when an exception is thrown.

Can anyone help me??

frederikherema1
Star Contributor
Star Contributor
You can use logical error-boundary caching events, that react to BPMNErrors you throw from your code. After thrown, you can model an additional service-task (after the error-catch) that rolls back any external logic that has been performed in the failed service-task1. Check the user guide for correct usage.