How to migrate connection-per-host option in mongodb-java-driver-legacy to mongodb-java-driver-sync?

Hi, I try to migrate mongodb-java-driver-legacy to mongodb-java-driver-sync, but I can found connection-per-host option in mongo client settings.

how can i migrate that option?

Thx!

See https://www.mongodb.com/docs/drivers/java/sync/v4.3/fundamentals/connection/mongoclientsettings/#std-label-mcs-connectionpool-settings.

It’s the maxSize property on ConnectionPoolSettings, e.g.

var settings = MongoClientSettings.builder()
    .applyConnectionString(new ConnectionString("<your connection string>"))
    .applyToConnectionPoolSettings(builder ->
        .maxSize(200)
    .build()