Class TransactionsConfig.Builder
- Enclosing class:
- TransactionsConfig
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Deprecated.This method clobbers any previously configured values.cleanupConfig
(Consumer<TransactionsCleanupConfig.Builder> builderConsumer) Passes theTransactionsCleanupConfig.Builder
to the provided consumer.durabilityLevel
(DurabilityLevel level) All transaction writes will be performed with this durability setting.metadataCollection
(TransactionKeyspace collection) Allows setting a custom collection to use for any transactional metadata documents.queryConfig
(TransactionsQueryConfig.Builder queryConfig) Deprecated.This method clobbers any previously configured values.queryConfig
(Consumer<TransactionsQueryConfig.Builder> builderConsumer) Passes theTransactionsQueryConfig.Builder
to the provided consumer.Sets the maximum time that transactions can run for.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
-
cleanupConfig
@Deprecated public TransactionsConfig.Builder cleanupConfig(TransactionsCleanupConfig.Builder config) Deprecated.This method clobbers any previously configured values. Please usecleanupConfig(Consumer)
instead.Configures transaction cleanup. -
cleanupConfig
@Uncommitted public TransactionsConfig.Builder cleanupConfig(Consumer<TransactionsCleanupConfig.Builder> builderConsumer) Passes theTransactionsCleanupConfig.Builder
to the provided consumer.Allows customizing transaction cleanup options.
- Parameters:
builderConsumer
- a callback that configures options.- Returns:
- this builder for chaining purposes.
-
timeout
Sets the maximum time that transactions can run for. The default is 15 seconds. After this time, transactions will throw aTransactionExpiredException
error.Applications can increase or decrease this as desired. The trade-off to understand is that documents that are being mutated in a transaction A, are effectively locked from being updated by other transactions until transaction A has completed - committed or rolled back. If transaction A is unable to complete for whatever reason, the document can be locked for this
expirationTime
time.It is worth noting that this setting does not completely guarantee that the transaction will immediately be completed after that time. In some rare cases, such as application crashes, it may take longer as the lost transactions cleanup process will be involved.
-
durabilityLevel
All transaction writes will be performed with this durability setting.All writes in Couchbase go initially to one primary node, and from their fan-out to any configured replicas.
If durability is disabled then the transaction will continue as soon as the write is available on the primary node. The durability setting will ensure the transaction does not continue until the write is available in more places. This can provide a small degree of extra security in the advent of node loss.
The default setting is DurabilityLevel.MAJORITY, meaning a transaction will pause on each write until it is available in-memory on a majority of configured replicas.
-
metadataCollection
Allows setting a custom collection to use for any transactional metadata documents.If not set, it will default to creating these documents in the default collection of the bucket that the first mutated document in the transaction is on.
This collection will be added to the set of collections being cleaned up.
-
queryConfig
@Deprecated public TransactionsConfig.Builder queryConfig(TransactionsQueryConfig.Builder queryConfig) Deprecated.This method clobbers any previously configured values. Please usequeryConfig(Consumer)
instead.Sets the default query configuration for all transactions.- Parameters:
queryConfig
- the query configuration to use- Returns:
- this, for chaining
-
queryConfig
public TransactionsConfig.Builder queryConfig(Consumer<TransactionsQueryConfig.Builder> builderConsumer) Passes theTransactionsQueryConfig.Builder
to the provided consumer.Allows customizing the default options for all transactional queries.
- Parameters:
builderConsumer
- a callback that configures options.
-