Hi, I have a scenario were i invoke my application's service API from within activiti's ServiceTask. Now in case if the Service API throws an exception, i would like to terminate the processInstance, and also retain the history details as i require it to fetch the status of the workflow at a later point of time using the processInstanceId. To achieve this I wrapped all the ServiceTask logic inside a try catch block and then whenever an exception occurs i catch the exception and would like to terminate the processInstance using the runtimeService.deleteProcessInstance(pid).
Theoretically i expected things to work, but Activiti(5.11) throws an NPE @ AbstractBpmnActivityBehaviour.hasCompensationHandler(), Is it an expected behavior? or a bug with activiti?
Could anyone please help me out in achieving the said behavior?
One way which i could think of is to wrap the tasks inside a sub-process and to have an error Boundary event on the sub-process boundary which ends the execution.
Is there any way of triggering an End-Event from within the ServiceTask programmatically ??
Could anyone please guide me in the right direction.
The best way to do this is add an error boundary event to the service task or an exclusive gateway after the service task that checks if the exception has occurred. If an exception occurred it goes to an end event otherwise it just continues the normal flow.