clemp6r
clemp6r

Reputation: 3723

How to specify the replicaSet name with ReactiveMongo?

When opening a connection to multiple mongoDB servers with ReactiveMongo, we can pass it a list of hosts to connect to.

However I don't find any way to provide the replicaSet name (as we can do in standard MongoDB URIs). Even the URI parser of ReactiveMongo ignores it.

Is it a problem? Will the driver it work correctly without knowledge of the replicaSet name?

Upvotes: 2

Views: 545

Answers (1)

Markus W Mahlberg
Markus W Mahlberg

Reputation: 20703

The list you provide is called "seed list". When your driver connects to one of these servers, be it a primary or secondary, the driver will be informed that it connected to the replica set and which server is the current primary (if there is one) amongst other details.

Your driver even should be informed when a new primary elected and it should automatically connect to the newly elected primary.

As per ReactiveMongo docs which you should read throughly:

[...]ReactiveMongo provides support for Replica Sets. That means the following:

  • the driver will detect if it is connected to a Replica Set;
  • it will probe for the other nodes in the set and connect to them;
  • it will detect when the primary has changed and guess which is the new one;

[...]

Upvotes: 3

Related Questions