Package com.mongodb
Class TransactionOptions.Builder
java.lang.Object
com.mongodb.TransactionOptions.Builder
- Enclosing class:
- TransactionOptions
The builder for transaction options
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the transaction options instance.maxCommitTime
(Long maxCommitTime, TimeUnit timeUnit) Sets the maximum execution time on the server for the commitTransaction operation.readConcern
(ReadConcern readConcern) Sets the read concern.readPreference
(ReadPreference readPreference) Sets the read preference.Sets the time limit for the full execution of the operations for this transaction.writeConcern
(WriteConcern writeConcern) Sets the write concern.
-
Method Details
-
readConcern
Sets the read concern.- Parameters:
readConcern
- the read concern- Returns:
- this
-
writeConcern
Sets the write concern.- Parameters:
writeConcern
- the write concern, which must be acknowledged- Returns:
- this
-
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
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 unittimeUnit
- the time unit, which may not be null- Returns:
- this
- Since:
- 3.11
- Since server release
- 4.2
-
timeout
Sets the time limit for the full execution of the operations for this transaction.null
means that the timeout mechanism for operations will defer to using:waitQueueTimeoutMS
: The maximum wait time in milliseconds that a thread may wait for a connection to become availablesocketTimeoutMS
: How long a send or receive on a socket can take before timing out.wTimeoutMS
: How long the server will wait for the write concern to be fulfilled before timing out.maxTimeMS
: The cumulative time limit for processing operations on a cursor. See: cursor.maxTimeMS.maxCommitTimeMS
: The maximum amount of time to allow a singlecommitTransaction
command to execute.
0
means infinite timeout.> 0
The time limit to use for the full execution of an operation.
- Parameters:
timeout
- the timeouttimeUnit
- the time unit- Returns:
- this
- Since:
- 5.2
-
build
Build the transaction options instance.- Returns:
- The
TransactionOptions
-