My xml config file looks like this. I want to set maxWaitQueueSize from defult value (50) to value 500. So I decided to add propertyname="connectionsPerHost" in my xml file. But I can't find any option for this along with
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<mongo:mongo id="mongoid" host="${mongo.host}" port="${mongo.port}" />
I know I can do this by adding the below code in my xml but not sure how to add it along with <mongo:mongo id="mongoid">
tag.
<bean id="options" class="com.mongodb.MongoOptions">
<property name="connectionsPerHost" value="${mongo.db.pool.size}"/>
</bean>
I tried this one:
<mongo:mongo id="mongoid" host="${mongo.host}" port="${mongo.port}">
<mongo:options connections-per-host="500" />
</mongo:mongo>
but getting exception like:
Caused by: java.lang.IllegalArgumentException: Usage of 'mongo-options' is no longer supported for MongoDB Java driver version 3 and above. Please use 'mongo-client-options' and refer to chapter 'MongoDB 3.0 Support' for details.
at org.springframework.data.mongodb.core.MongoOptionsFactoryBean.createInstance(MongoOptionsFactoryBean.java:221)
at org.springframework.data.mongodb.core.MongoOptionsFactoryBean.createInstance(MongoOptionsFactoryBean.java:36)
at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 55 more
Got the answer from documentation.
spring-mongo-1.8.xsd
tospring-mongo-1.8.xsd
inxsi:schemaLocation
Modified the code like:
This worked for me.