cancel
Showing results for 
Search instead for 
Did you mean: 

handling exceptions with activiti agnostic spring beans

cirerenat
Champ in-the-making
Champ in-the-making
See the attached flow. Both service tasks updateA and updateB are spring beans and they are called as "expression". They have no knowledge of they're being called from activiti and we want to leave them like that. And this process (svc_persist) is called from a service layer.

// Initialize the execution variables
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processId,vars);
// When process is finished
Map<String, Object> outputVars = runtimeService.getVariables(processInstance.getId());

The issue is handling the exceptions. If an exception thrown from any of the service tasks, the service layer would have no way of dealing with the exception and returning a some how meaningful response to the caller.

In some flows we have tens of service beans calling the activiti agnostic beans. How can I wrap these process flows to have more control over exceptions.
3 REPLIES 3

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
You could write a small generic 'Activity-agnostic-springbean-wrapper' and use that.

cirerenat
Champ in-the-making
Champ in-the-making
Is the wrapper going to be for each tasks? But that means I would need to change my flows to check  some kind of return code after each service task, right ?.
e.g. In the simple flow I've posted, I would need a exclusive gateway after updateA to check if updateA was successful and move on to updateB. In a simplified process with two/three tasks, it sounds reasonable, but when you have more tasks, the flow starts to looks like London subway map  Smiley Very Happy. One of the appeals of using activiti was to share the flow diagrams with business people and we would like to keep them not too complicated.

Maybe I didn't understand your suggestion, if you can elaborate a little, I'd really appreciate.

Is it possible to implement a wrapper for 'Call Activiti' task ? Then without changing my original flows, I'll prepare a new flow which would consists nothing but the call activiti wrapper. But how can this be implemented ?

Also, Can using Listeners be an option ?

cirerenat
Champ in-the-making
Champ in-the-making
Any activiti gurus out there want to chime in? Am I getting the vibe that using spring beans are not that welcome ? Using delegates would have been a better choice ?