Class Transactions
java.lang.Object
com.couchbase.client.java.transactions.Transactions
The starting point for accessing Couchbase transactions.
 
 The main methods to run transactions are run(java.util.function.Consumer<com.couchbase.client.java.transactions.TransactionAttemptContext>, com.couchbase.client.java.transactions.config.TransactionOptions) and reactive.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionrun(Consumer<TransactionAttemptContext> transactionLogic) Runs supplied transactional logic until success or failure.run(Consumer<TransactionAttemptContext> transactionLogic, TransactionOptions options) Runs supplied transactional logic until success or failure.
- 
Constructor Details- 
Transactions
 
- 
- 
Method Details- 
runpublic TransactionResult run(Consumer<TransactionAttemptContext> transactionLogic, @Nullable TransactionOptions options) Runs supplied transactional logic until success or failure.The supplied transactional logic will be run if necessary multiple times, until either: - The transaction successfully commits
- The transactional logic requests an explicit rollback
- The transaction timesout.
- An exception is thrown, either inside the transaction library or by the supplied transaction logic, that cannot be handled.
 The transaction logic Consumeris provided aTransactionAttemptContext, which contains methods allowing it to perform all operations that are possible inside a transaction.Commit will be performed automatically if the lambda successfully reaches its end. - Parameters:
- transactionLogic- the application's transaction logic
- options- the configuration to use for this transaction
- Returns:
- there is no need to check the returned TransactionResult, as success is implied by the lack of a thrown exception. It contains information useful only for debugging and logging.
- Throws:
- TransactionFailedException- or a derived exception if the transaction fails to commit for any reason, possibly after multiple retries. The exception contains further details of the error
 
- 
runRuns supplied transactional logic until success or failure. A convenience overload forrun(java.util.function.Consumer<com.couchbase.client.java.transactions.TransactionAttemptContext>, com.couchbase.client.java.transactions.config.TransactionOptions)that provides a defaultTransactionOptions
 
-