Hi,
We are using mongo replica set in spring mongo db integration and we observed that if all the nodes of the mongo db are down, requests (e.g. mongoTemplate.save) hang for about 60-120 seconds and then throw an exception. Following is the configuration we are using, the behavior is same whether we use mongo options or not. We are using mongo db for logging purpose only which is used for logging requests and responses and want even if all nodes of the mongo db are down, requests should not hang (if these fail, these should exit immediately)
<mongo:mongo id="mongo" replica-set="${nosql.db.replicaset}">
<mongo:options
connect-timeout="1000"
max-wait-time="1500"
auto-connect-retry="true"
socket-keep-alive="true"
socket-timeout="1500"
slave-ok="true"
write-number="1"
write-timeout="1000"
write-fsync="true"/>
</mongo:mongo>
<bean id="mongoCredentials" class="org.springframework.data.authentication.Use rCredentials">
<constructor-arg name="username" value="${nosql.db.username}" />
<constructor-arg name="password" value="${nosql.db.password}" />
</bean>
<!-- configure mongodb template to access the mongodb services -->
<bean id="mongoTemplate"
class="org.springframework.data.mongodb.core.Mongo Template">
<constructor-arg ref="mongo"/>
<constructor-arg name="databaseName" value="${nosql.db.name}" />
<constructor-arg name="userCredentials" ref="mongoCredentials"/>
</bean>
Google does not show many similar results.
Any help is highly appreciated.
Thanks,
We are using mongo replica set in spring mongo db integration and we observed that if all the nodes of the mongo db are down, requests (e.g. mongoTemplate.save) hang for about 60-120 seconds and then throw an exception. Following is the configuration we are using, the behavior is same whether we use mongo options or not. We are using mongo db for logging purpose only which is used for logging requests and responses and want even if all nodes of the mongo db are down, requests should not hang (if these fail, these should exit immediately)
<mongo:mongo id="mongo" replica-set="${nosql.db.replicaset}">
<mongo:options
connect-timeout="1000"
max-wait-time="1500"
auto-connect-retry="true"
socket-keep-alive="true"
socket-timeout="1500"
slave-ok="true"
write-number="1"
write-timeout="1000"
write-fsync="true"/>
</mongo:mongo>
<bean id="mongoCredentials" class="org.springframework.data.authentication.Use rCredentials">
<constructor-arg name="username" value="${nosql.db.username}" />
<constructor-arg name="password" value="${nosql.db.password}" />
</bean>
<!-- configure mongodb template to access the mongodb services -->
<bean id="mongoTemplate"
class="org.springframework.data.mongodb.core.Mongo Template">
<constructor-arg ref="mongo"/>
<constructor-arg name="databaseName" value="${nosql.db.name}" />
<constructor-arg name="userCredentials" ref="mongoCredentials"/>
</bean>
Google does not show many similar results.
Any help is highly appreciated.
Thanks,