diff --git a/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/configuration/nonhuman/MongoConfiguration.java b/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/configuration/nonhuman/MongoConfiguration.java index 52c2bbec1..ad055c95c 100644 --- a/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/configuration/nonhuman/MongoConfiguration.java +++ b/eva-accession-core/src/main/java/uk/ac/ebi/eva/accession/core/configuration/nonhuman/MongoConfiguration.java @@ -18,6 +18,8 @@ import com.mongodb.MongoClient; import com.mongodb.MongoClientOptions; +import com.mongodb.ReadPreference; +import com.mongodb.WriteConcern; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -91,6 +93,8 @@ public MongoTemplate mongoTemplate(@Qualifier("primaryFactory") MongoDbFactory m MappingMongoConverter converter) { converter.setTypeMapper(new DefaultMongoTypeMapper(null)); MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory, converter); + mongoTemplate.setWriteConcern(WriteConcern.MAJORITY); + mongoTemplate.setReadPreference(ReadPreference.valueOf(readPreference)); mongoTemplate.setWriteResultChecking(WriteResultChecking.EXCEPTION); return mongoTemplate; }