How can I solve MongoWaitQueueFullException?

淺唱寂寞╮ 提交于 2019-12-05 19:49:55

You need to check what is the connections per host value which you have given while setting up connection (looking at the exception I think you would have set it to 500).

MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
builder.connectionsPerHost(200);
MongoClientOptions options = builder.build();
mongoClient = new MongoClient(URI, connectionOptions);

An ideal way of setting the connections per host would be by trial and error but you need to make sure that the value which you set should not exceed the number of connections you can have by opening the mongo shell and executing:

db.serverStatus().connections.available

you are in maxWaitQueueSize limit , so increase multiplier ;)

 MongoClientOptions options = MongoClientOptions.builder()
                .threadsAllowedToBlockForConnectionMultiplier(10)
                .build();

 MongoClient mongo = new MongoClient("127.0.0.1:27017", options);
 //run 2000 threads and use database ;)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!