cancel
Showing results for 
Search instead for 
Did you mean: 

ActivitiException causing rollback inspite of catching it

hepci123
Champ in-the-making
Champ in-the-making
Hi,

We are using Spring+Activiti+JTA in our application. The method that calls RuntimeService.startProcessInstanceByKey has a try catch for ActivitiException as we do not want the transaction to be rolled back when the exception occurs. But everytime ActivitException occurs I see that the transaction is getting rolled back, in my case jms queue is also transacted, so the roll back is causing the message to be redelivered causing an infitnite loop.

Tried many things to stop the roll back and redelivery of the message like
1. removed activiti retry by following the instructions given in http://forums.activiti.org/content/job-retry-defaults , thinking that may be activiti retries on failure is causing the redelivery but bo luvk with it.
2. added noRollBackFor=ActivitiException.class at transactional annotation for the method that calls RuntimeService.startProcessInstanceByKey , still no luck ( as acitiviti is throwing this exception and not the my method that is calling activiti)
3. changed the propogation of this method to 'requries_new' but still bo use.

During my research, I read that Spring rollsback every runtime exception. As ActivitiException extends RTE, is there anyway I can stop Spring from marking this transaction for rollback. Been looking into this issue for a ouple days now and I'm getting nowhere. Any help in this regard is very much appreciated.
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Why is your process instance throwing an ActivitiException? Is it happening in a service task? Then you could catch the Exception there. You can also use asynchronous activities to commit the transaction after the process instance is started.

Best regards,

hepci123
Champ in-the-making
Champ in-the-making
Hi,

Thank you for your response.

A gateway in one of our workflows was missing default flow so everytime the gateway conditions are not met, activiti is throwing below exception

org.activiti.engine.ActivitiException: No outgoing sequence flow of the exclusive gateway 'actionBlockGateway' could be selected for continuing the process

Even though poorly constructed workflow caused this exception in the above scenario, we still need to handle such scenarios as our customers are creating these and may not be as familiar with activiti.

Our workflow tasks need to be executed sequentially so I don't think using async tasks suits our implementation. We have disabled JTA on the queue for now as we had a release. We'll soon need to figure out how to stop this loop due to Spring rollback on ActivitiException and release a patch. Any help in this regard is great!

Thanks!

jbarrez
Star Contributor
Star Contributor
If your transaction management is configured correctly, this should work. I suspect a misconfiguration.

How does your transaction config look like (Spring-side and Actviiti-side) ?

An alternative is to add your own command (copied from the regular start process instance command, but now with an exception catch), execute it through managementService.executeCommand.().