|
The MongoDB Java driver handles failover in replicated setups with tunable levels of transparency to the user. By default, a Mongo connection object will ignore failures of secondaries, and only reads will throw MongoExceptions when the primary node is unreachable. The level of exception reporting is tunable however, using a specific WriteConcern; you can set this on the Mongo/DB/Collection/Method level. Several levels are included as static options:
Sample code is provided which illustrates some of these options. To quickly initialize a sample replica set, you can use the mongo shell: > var rst = new ReplSetTest({ nodes : 3 }) > rst.startSet() // wait for processes to start > rst.initiate() // wait for replica set initialization Java client code demonstrating error handling is available : |

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus