//TODO: make connection options configurable
@Bean
    public MongoClient mongoClient() {
        MongoClientOptions.Builder options = MongoClientOptions.builder()   //TODO: make connection options configurable
                .connectionsPerHost(4)
                .maxConnectionIdleTime(60000)
                .maxConnectionLifeTime(120000);
        ServerAddress serverAddress = new ServerAddress(mongoConfiguration.getHost(), mongoConfiguration.getPort());
        MongoCredential credential = getCredentials(mongoConfiguration.getAuth());
        if (credential == null) {
            LOG.info("Connecting to mongo without auth");
        } else {
            LOG.info("Mongo credential: user: '{}', password: '***', authenticationDatabase: '{}'", mongoConfiguration.getAuth().getUser(), mongoConfiguration.getAuth().getAuthBase());
        }
        return credential == null ? new MongoClient(serverAddress) :
                new MongoClient(serverAddress, Collections.singletonList(credential), options.build());
    }
@Bean
public MongoClient mongoClient() {
MongoClientOptions.Builder options = MongoClientOptions.builder() //TODO: make connection options configurable
.connectionsPerHost(4)
.maxConnectionIdleTime(60000)
@Bean
public MongoClient mongoClient() {
MongoClientOptions.Builder options = MongoClientOptions.builder() //TODO: make connection options configurable
.connectionsPerHost(4)
.maxConnectionIdleTime(60000)
.maxConnectionLifeTime(120000);
ServerAddress serverAddress = new ServerAddress(mongoConfiguration.getHost(), mongoConfiguration.getPort());
MongoCredential credential = getCredentials(mongoConfiguration.getAuth());
if (credential == null) {
LOG.info("Connecting to mongo without auth");
} else {
LOG.info("Mongo credential: user: '{}', password: '***', authenticationDatabase: '{}'", mongoConfiguration.getAuth().getUser(), mongoConfiguration.getAuth().getAuthBase());
}
@Bean
public MongoClient mongoClient() {
MongoClientOptions.Builder options = MongoClientOptions.builder() //TODO: make connection options configurable
.connectionsPerHost(4)
.maxConnectionIdleTime(60000)
.maxConnectionLifeTime(120000);
ServerAddress serverAddress = new ServerAddress(mongoConfiguration.getHost(), mongoConfiguration.getPort());
MongoCredential credential = getCredentials(mongoConfiguration.getAuth());
if (credential == null) {
LOG.info("Connecting to mongo without auth");
} else {
LOG.info("Mongo credential: user: '{}', password: '***', authenticationDatabase: '{}'", mongoConfiguration.getAuth().getUser(), mongoConfiguration.getAuth().getAuthBase());
}
return credential == null ? new MongoClient(serverAddress) :
new MongoClient(serverAddress, Collections.singletonList(credential), options.build());
}