'How to configure mongos in Spring boot?

I am configuring MongoDB shards wherein each shard will be a replica set consisting of three nodes and config servers will be another replica set consisting of 3 nodes again.

But my spring boot application is connecting to the router i.e. mongos to interact with the Shards. AFAIK the mongos instances cant be formed as a replica set, also spring boot does not provide an option to give a list of mongos hosts.

So, I am afraid mongos will be a single point of failure. Is there any way that I configure mongos in spring boot so that if one of mongos instances is not reachable, our application automatically connects to other mongos instance?

NOTE: I am using spring-data-mongodb

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source