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
Modifier and TypeInterfaceDescriptionstatic class
Holds the configuration information that is required when applying retry logic. -
Method Summary
Modifier and TypeMethodDescriptionint
Get the current transaction attempt number in the inner-most active transaction.int
getAttemptNumber
(String transactionManagerName) Get the current transaction attempt number for the specified transaction manager.long
Get the aspect-wide default forRetryTransaction.initialDelay()
.long
Get the aspect-wide default forRetryTransaction.maximumDelay()
.int
Get the aspect-wide default forRetryTransaction.maxRetries()
.Get the configured exception translator.<T> T
retry
(RetryTransactionProvider.RetrySetup<T> setup) Perform a transaction, retrying as necessary.void
setInitialDelayDefault
(long initialDelayDefault) Set the aspect-wide default forRetryTransaction.initialDelay()
.void
setMaximumDelayDefault
(long maximumDelayDefault) Set the aspect-wide default forRetryTransaction.maximumDelay()
.void
setMaxRetriesDefault
(int maxRetriesDefault) Set the aspect-wide default forRetryTransaction.maxRetries()
.void
setPersistenceExceptionTranslator
(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
- ifsetup
is null
-