Looking at sitewhere-mongodb project source code. Sitewhere uses another MongoDB client.
The code shows that sitewhere only connect to one mongodb hostname & one mongodb port. To connect to a replica set with this mongodb client, you need to modify source code to connect sitewhere to a list of mongodb servers.
String[] hosts; // array of mongodb hostnames
String[] ports; // array of mongodb ports
List<ServerAddress> servers = new ArrayList<>();
try {
for (int i=0; i<hosts.length; i++) {
servers.add(new ServerAddress(hosts[i], Integer.parseInt(ports[i])));
}
} catch (Exception e) {
throw new RuntimeException("Invalid Mongodb Configuration");
}
LOGGER.info("Mongodb server list: " + servers);
// Handle authenticated access.
if ((getUsername() != null) && (getPassword() != null)) {
MongoCredential credential =
MongoCredential.createCredential(getUsername(), getDatabaseName(),
getPassword().toCharArray());
this.client =
new MongoClient(servers,
Arrays.asList(credential), builder.build());
}