AnsweredAssumed Answered

Exception handling and RetryingTransactionHelper -- howto?

Question asked by mastro on Mar 27, 2012
Latest reply on Mar 28, 2012 by mastro
I filed a bug here: https://issues.alfresco.com/jira/browse/ALF-13462

After a reply from David I discovered I shouldn't have had catch the exception in my custom class: but couldn't find any documentation about it… Usually catching exception is a good practice!

I'm willing to write a better guide lines in http://wiki.alfresco.com/wiki/Coding_Standards from the result of this forum conversation.

I gave a look at the RetryingTransactionHelper class and I've seen it re-try the same action over and over again until it success or until a pre-defined number of retries fails…

Question is: how do I handle exception in my custom classes?

What if I need to invoke some external service? And later the action fail? In that case I can't effort re-calling the same service twice.

Furthermore the service return a org.alfresco.service.cmr.rendition.RenditionServiceException: which can be caused by IO exception or other issue, are you saying that I should use  RetryingTransactionHelper.extractRetryCause() to know if I should re-throw the exception or handle it?

For actions I've see there is the possibility of creating compensating action: does it get call if the last retry fail?
Can I pass it arguments on why it failed?

Finally,  how do I do that from policy behavior or webscripts?

I can use thread locals to store state and somewhat know if this is the last retry and thus acting properly… but I found this an horrible workaround.

So, which is the "right" way to handle exception with alfresco on a custom code?

Outcomes