Hi! I'm using spring data to work with mongodb. When number connections increasing, time of query become very long (1 seconds - 13 seconds Oo). When requests go from users - mongodb is very fast (9 ms - 40 ms), but if RabbitMqListener uses mongodb, that time of query become very long. RabbitMqListener work on 10 Concurrent Consumers.
My beans:
Code:@Bean @Scope("singleton") public MongoDbFactory mongoDbFactory() throws Exception { MongoOptions options = new MongoOptions(); // options.setConnectionsPerHost(50); // options.setThreadsAllowedToBlockForConnectionMultiplier(10); UserCredentials userCredentials = new UserCredentials(Const.mongoConfiguration.getUser(), Const.mongoConfiguration.getPwd()); return new SimpleMongoDbFactory(new Mongo(Const.mongoConfiguration.getHost(), options), Const.mongoConfiguration.getDatabase_name(), userCredentials); }They should be to make singleton ?Code:@Bean @Scope("singleton") public MongoTemplate mongoTemplate() throws Exception { MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory()); return mongoTemplate; }
How can I fix this error?


Reply With Quote