AnsweredAssumed Answered

How to write code with transactions

Question asked by hbf on Jun 24, 2008
Latest reply on Jan 15, 2015 by vikashkaushik
Dear list,

I need advice on how to use Alfresco transactions in my custom code. As far as I understand the Alfresco APIs, there are two ways to use transactions:

1. Create the transaction, begin() it, do the work, and eventually call commit() or rollback().
2. Do the work within a RetryingTransactionHelper's RetryingTransactionCallback.

The first approach can be difficult because, it seems, a transaction may fail due to concurrency issues, see this post. So it seems it's best to use approach 2.

However, the work I do in a transaction is spread over different classes/methods/places and I cannot easily write a single RetryingTransactionCallback that does it all. Therefore my question: is there maybe a third way to do work within a transaction that gets retried in case of concurrency issues?

Many thanks,
Kaspar

Outcomes