Package com.mongodb

Class TransactionOptions.Builder

  • Enclosing class:
    TransactionOptions

    public static final class TransactionOptions.Builder
    extends Object
    The builder for transaction options
    • Method Detail

      • readPreference

        public TransactionOptions.Builder readPreference​(@Nullable
                                                         ReadPreference readPreference)
        Sets the read preference.
        Parameters:
        readPreference - the read preference, which currently must be primary. This restriction may be relaxed in future versions.
        Returns:
        this
      • maxCommitTime

        public TransactionOptions.Builder maxCommitTime​(@Nullable
                                                        Long maxCommitTime,
                                                        TimeUnit timeUnit)
        Sets the maximum execution time on the server for the commitTransaction operation.
        Parameters:
        maxCommitTime - the max commit time, which must be either null or greater than zero, in the given time unit
        timeUnit - the time unit, which may not be null
        Returns:
        this
        Since:
        3.11
        Since server release
        4.2
      • build

        public TransactionOptions build()
        Build the transaction options instance.
        Returns:
        The TransactionOptions