Class TransactionsConfig.Builder

Enclosing class:

public static class TransactionsConfig.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

    • cleanupConfig

      Configures transaction cleanup.
    • timeout

      public TransactionsConfig.Builder timeout(Duration timeout)
      Sets the maximum time that transactions can run for. The default is 15 seconds. After this time, transactions will throw a TransactionExpiredException 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

      public TransactionsConfig.Builder durabilityLevel(DurabilityLevel level)
      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

      public TransactionsConfig.Builder metadataCollection(TransactionKeyspace collection)
      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

      Sets the default query configuration for all transactions.
      queryConfig - the query configuration to use
      this, for chaining