Java Reference
In-Depth Information
Retrying transactions
Transactions that are rolled back because of a recoverable error such as an optimis-
tic locking failure should be retried. A convenient way to automatically retry a trans-
action is to use an AOP interceptor that catches exceptions that indicate recoverable
errors and then retries the transaction. Figure 8.7 shows what happens when a trans-
action is retried. In this design, the PlaceOrderService is wrapped with the Trans-
actionRetryInterceptor , which is a custom AOP interceptor that is described in
more detail in chapter 12, and the regular Spring TransactionInterceptor .
: Transaction
RetryInterceptor
: Transaction
I nterceptor
: PlaceOrder
Service
: Persistence
Framework
: Servlet
service()
updateDeliveryInfo()
updateDeliveryInfo()
beginTxn()
serviceMethod()
rollbackTxn()
updateDeliveryInfo( )
beginTxn()
serviceMethod()
commitTxn()
Figure 8.7
Retrying a transaction with an AOP interceptor
 
 
Search WWH ::




Custom Search