Package com.blazebit.job.spi
Interface TransactionSupport
-
public interface TransactionSupport
Interface implemented by the job implementation provider. Implementations are instantiated viaServiceLoader
.- Since:
- 1.0.0
- Author:
- Christian Beikov
-
-
Field Summary
Fields Modifier and Type Field Description static TransactionSupport
NOOP
The no-op transaction support that has no transactional support.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
registerPostCommitListener(Runnable o)
Registers the given runnable to run after a commit.<T> T
transactional(JobContext context, long transactionTimeoutMillis, boolean joinIfPossible, Callable<T> callable, Consumer<Throwable> exceptionHandler)
Runs the given callable in a transaction with the given transaction timeout.
-
-
-
Field Detail
-
NOOP
static final TransactionSupport NOOP
The no-op transaction support that has no transactional support. This is the default.
-
-
Method Detail
-
transactional
<T> T transactional(JobContext context, long transactionTimeoutMillis, boolean joinIfPossible, Callable<T> callable, Consumer<Throwable> exceptionHandler)
Runs the given callable in a transaction with the given transaction timeout. If desired, will join an already running transaction, otherwise, will suspend an already running transaction and start a new one. If an exception happens in the callable, the exception handler is invoked.- Type Parameters:
T
- The result type of the callable- Parameters:
context
- The job contexttransactionTimeoutMillis
- The transaction timeoutjoinIfPossible
- Whether to join an existing transaction or create a new onecallable
- The callable to execute within the transactionexceptionHandler
- The exception handler to invoke if an exception occurs- Returns:
- the result of the callable
-
registerPostCommitListener
void registerPostCommitListener(Runnable o)
Registers the given runnable to run after a commit.- Parameters:
o
- The runnable to run after a commit
-
-