Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2166

Make it easier to mix ConnectionString settings with MongoClientSettings

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.7.0
    • Affects Version/s: None
    • Component/s: Async, Configuration
    • None

      Currently, mixing settings is extremely verbose compared to MongoClientURI.

      A recent example is a user (SCALA-243) wanting to set the serverSelectionTimeoutMS in the Scala driver is:

      val connectionString = new ConnectionString("mongodb://localhost/?connectTimeoutMS=500&socketTimeoutMS=500")
      val mongoClientSettings = MongoClientSettings.builder()
        .clusterSettings(ClusterSettings.builder().applyConnectionString(connectionString).serverSelectionTimeoutMS(500).build())
        .connectionPoolSettings(ConnectionPoolSettings.builder().applyConnectionString(connectionString).build())
        .serverSettings(ServerSettings.builder().build()).credentialList(connectionString.getCredentialList)
        .sslSettings(SslSettings.builder().applyConnectionString(connectionString).build())
        .socketSettings(SocketSettings.builder().applyConnectionString(connectionString).build())
        .build()
          
      MongoClient(mongoClientSettings)
      

      Which is very verbose compared to the Sync driver:

      String connectionString = "mongodb://localhost/?connectTimeoutMS=500&socketTimeoutMS=500";
      MongoClientURI connectionStringAndOptions = new MongoClientURI(connectionString, MongoClientOptions.builder().serverSelectionTimeout(200));
      new MongoClient(uriAndOptions); 
      

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            ross@mongodb.com Ross Lawley
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: