Quantcast
Channel: Spring Community Forums - NoSQL
Viewing all articles
Browse latest Browse all 128

Configuring read preferences for MongoDB in Spring Data on collection level

$
0
0
I am using Spring Data MongoDB latest version 1.1.1RELEASE and wondering if it possible to add read preference on collection level. Something that possible with plain MongoDB driver. I want all my reads for particular collection go to the slaves to distrubute read operations. Is that possible?

From mongo driver documentation:

Continuing with our sample application, we decide that we want to send our read requests to the nearest node to reduce request latency. The Java driver’s read preference API gives a couple of ways of doing this, the easiest is to simply use the nearest mode.

DBObject query = new BasicDBObject("name", "simple doc")
DBObject result =
coll.findOne(query, null, ReadPreference.nearest());
"

Thanks

Viewing all articles
Browse latest Browse all 128

Trending Articles