I am using MongoOptions
class and its methods
setFsync(boolean sync)
setJ(boolean safe)
setW(int val)
setWtimeout(int timeoutMS)
setSafe(boolean isSafe)
How to achieve this using MongoClientOptions
as MongoOptions
is depracated in Mongo-Java-Driver 3.0. I came to know MongoClientOptions
uses
MongoClientOptions.builder()
to create a new Builder instance and then append properties.
@Immutable public class MongoClientOptions extends Object. Various settings to control the behavior of a MongoClient . Note: This class is a replacement for MongoOptions , to be used with MongoClient . The main difference in behavior is that the default write concern is WriteConcern.
To create a MongoClientSettings object, use the MongoClientSettings. builder() method and chain methods to specify your settings. After chaining them, use the build() method to create the MongoClientSettings object. Adds a listener for command events.
Use the writeConcern method on the builder, as in:
MongoClientOptions options = MongoClientOptions.builder()
.writeConcern(WriteConcern.JOURNALED)
.build();
or
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With