google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

MongoDB Morphia Spring - how to configure replicatesets #431

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version are you using? (Morphia/Driver/MongoDB)
mongodb-win32-i386-2.0.2

Please include a stack trace below:

This is not related to stack trace

Question:
We are instantiating Mongo in Spring  as show below

Now we have 3 instances of Mongod running as part of replicasets. How to 
communicate to Morphia/Mongo to use replicate set.

Meaning what changes we need to make below to use above replicasets

<bean id="morphia" class="com.google.code.morphia.Morphia" />

<bean id="datastore" factory-bean="morphia" factory-method="createDatastore">

        <constructor-arg ref="mongo" />
        <constructor-arg value="${myprojectname.mongo.db.name}" />
    </bean>

<bean id="mongo" class="com.mongodb.Mongo">
        <constructor-arg value="${mongo.db.host}" type="java.lang.String" />
        <constructor-arg value="${mongo.db.port}" type="int" />
    </bean>

Original issue reported on code.google.com by javakish...@gmail.com on 26 Sep 2012 at 6:51

GoogleCodeExporter commented 9 years ago
You need to use the mongo constructor which takes a list. The list is the seeds 
used to find all the members of the set.

Original comment by scotthernandez on 27 Sep 2012 at 1:14