Package io.quarkus.narayana.jta
Class RunOptions
- java.lang.Object
-
- io.quarkus.narayana.jta.RunOptions
-
public class RunOptions extends Object
Builder interface to allow a transaction to be customized, including things like timeout and semantics when an existing transaction is present.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRunOptions.ExceptionResultstatic classRunOptions.SemanticEnum that can be used to control the transaction behaviour in the presence or absence of an existing transaction.
-
Field Summary
Fields Modifier and Type Field Description (package private) Function<Throwable,RunOptions.ExceptionResult>exceptionHandler(package private) RunOptions.Semanticsemantic(package private) inttimeout
-
Constructor Summary
Constructors Constructor Description RunOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RunOptionsexceptionHandler(Function<Throwable,RunOptions.ExceptionResult> handler)Provides an exception handler that can make a decision to rollback or commit based on the type of exception.RunOptionssemantic(RunOptions.Semantic semantic)Sets the transaction semantic that is used to determine the action to take if a transaction is already active.RunOptionstimeout(int seconds)Sets the transaction timeout for transactions created by this builder.
-
-
-
Field Detail
-
semantic
RunOptions.Semantic semantic
-
timeout
int timeout
-
exceptionHandler
Function<Throwable,RunOptions.ExceptionResult> exceptionHandler
-
-
Method Detail
-
timeout
public RunOptions timeout(int seconds)
Sets the transaction timeout for transactions created by this builder. A value of zero refers to the system default.- Parameters:
seconds- The timeout in seconds- Returns:
- This builder
- Throws:
IllegalArgumentException- If seconds is negative
-
semantic
public RunOptions semantic(RunOptions.Semantic semantic)
Sets the transaction semantic that is used to determine the action to take if a transaction is already active.- Parameters:
semantic- The semantic- Returns:
- This builder
-
exceptionHandler
public RunOptions exceptionHandler(Function<Throwable,RunOptions.ExceptionResult> handler)
Provides an exception handler that can make a decision to rollback or commit based on the type of exception. If the predicate returnsRunOptions.ExceptionResult.ROLLBACKthe transaction is rolled back, otherwise it is committed.This exception will still be propagated to the caller, so this method should not log or perform any other actions other than determine what should happen to the current transaction.
By default, the exception is always rolled back.
- Parameters:
handler- The exception handler- Returns:
- This builder
-
-