Package org.dellroad.stuff.spring
Interface RetryTransactionProvider
public interface RetryTransactionProvider
Interface implemented by the
RetryTransactionAspect, which implements the RetryTransaction functionality.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classHolds the configuration information that is required when applying retry logic. -
Method Summary
Modifier and TypeMethodDescriptionintGet the current transaction attempt number in the inner-most active transaction.intgetAttemptNumber(String transactionManagerName) Get the current transaction attempt number for the specified transaction manager.longGet the aspect-wide default forRetryTransaction.initialDelay().longGet the aspect-wide default forRetryTransaction.maximumDelay().intGet the aspect-wide default forRetryTransaction.maxRetries().Get the configured exception translator.<T> Tretry(RetryTransactionProvider.RetrySetup<T> setup) Perform a transaction, retrying as necessary.voidsetInitialDelayDefault(long initialDelayDefault) Set the aspect-wide default forRetryTransaction.initialDelay().voidsetMaximumDelayDefault(long maximumDelayDefault) Set the aspect-wide default forRetryTransaction.maximumDelay().voidsetMaxRetriesDefault(int maxRetriesDefault) Set the aspect-wide default forRetryTransaction.maxRetries().voidsetPersistenceExceptionTranslator(PersistenceExceptionTranslator persistenceExceptionTranslator) Set the configured exception translator.
-
Method Details
-
getPersistenceExceptionTranslator
PersistenceExceptionTranslator getPersistenceExceptionTranslator()Get the configured exception translator.- Returns:
- exception translator used to determine which transactions are retryable
-
setPersistenceExceptionTranslator
void setPersistenceExceptionTranslator(PersistenceExceptionTranslator persistenceExceptionTranslator) Set the configured exception translator.- Parameters:
persistenceExceptionTranslator- exception translator used to determine which transactions are retryable
-
getMaxRetriesDefault
int getMaxRetriesDefault()Get the aspect-wide default forRetryTransaction.maxRetries().- Returns:
- default maximum number of transaction retry attempts
-
setMaxRetriesDefault
void setMaxRetriesDefault(int maxRetriesDefault) Set the aspect-wide default forRetryTransaction.maxRetries().- Parameters:
maxRetriesDefault- default maximum number of transaction retry attempts
-
getInitialDelayDefault
long getInitialDelayDefault()Get the aspect-wide default forRetryTransaction.initialDelay().- Returns:
- default initial delay between retry attempts in milliseconds
-
setInitialDelayDefault
void setInitialDelayDefault(long initialDelayDefault) Set the aspect-wide default forRetryTransaction.initialDelay().- Parameters:
initialDelayDefault- default initial delay between retry attempts in milliseconds
-
getMaximumDelayDefault
long getMaximumDelayDefault()Get the aspect-wide default forRetryTransaction.maximumDelay().- Returns:
- default maximum delay between retry attempts in milliseconds
-
setMaximumDelayDefault
void setMaximumDelayDefault(long maximumDelayDefault) Set the aspect-wide default forRetryTransaction.maximumDelay().- Parameters:
maximumDelayDefault- default maximum delay between retry attempts in milliseconds
-
getAttemptNumber
int getAttemptNumber()Get the current transaction attempt number in the inner-most active transaction.Equivalent to
getAttemptNumber(null).- Returns:
- transaction attempt number, or zero if the aspect is not active in the current thread
-
getAttemptNumber
Get the current transaction attempt number for the specified transaction manager.- Parameters:
transactionManagerName- transaction manager name, or null to match all- Returns:
- transaction attempt number, or zero if the aspect is not active in the current thread for the transaction manager
-
retry
Perform a transaction, retrying as necessary.This method provides a way to apply retry logic directly without going through a method woven with the aspect.
- Type Parameters:
T- transaction return type- Parameters:
setup- retryable transaction setup- Returns:
- result from transaction
- Throws:
IllegalArgumentException- ifsetupis null
-