I am new to java and Mongo I am trying to set a max pool size of 100
I am running Load test in localhost I am seeing that the pool is getting re-used without any issues but the max pool size is not following the pool size I have given
for 10k calls there there are 300 connections in the pool where I have given only 100
not sure how this is happening
can any one help
----------------------- Code Start ----------------------------------
public class MongoFactory {
@Autowired
Environment environment;
private static MongoClient mongoClient;
private static String connectionString;
private static MongoDatabase database;
private static String USER_NAME;
private static String PASSWORD;
private static boolean createCollection = true;
@Autowired
EnvironmentVarUtil envUtil;
@Autowired
MongoWrapper mongoWrapper;
public void setConnectionString(String connectionString) {
this.connectionString = connectionString;
}
public String getConnectionString() {
return connectionString;
}
private static String mongoURIBuilder(String connectionString) {
return "mongodb+srv://" + USER_NAME + ":" + PASSWORD + "@" + connectionString + "/dbname?retryWrites=true&w=majority&connectTimeoutMS=30000&socketTimeoutMS=30000&maxPoolSize=100";
}
private void initMongoDB() {
if (USER_NAME == null) {
USER_NAME = envUtil.getEnvVar("mongoUserName");
}
if (PASSWORD == null) {
PASSWORD = envUtil.getEnvVar("mongoPassword");
}
String mongoURI = mongoURIBuilder(connectionString);
MongoClientURI uri = new MongoClientURI(mongoURI);
mongoClient = new MongoClient(uri);
String dbName = "dbname";
database = mongoClient.getDatabase(dbName);
}
public MongoObject load(MongoObject mongoObject) throws Exception
{
System.out.println("Start Time " +DateTime.now());
if(mongoClient==null)
{
initMongoDB();
}
// Get from DB code
System.out.println("End Time " +DateTime.now());
return mongoObject;
}
}