Skip to content

MongoDB Specific Features

Devender Yadav edited this page May 25, 2015 · 1 revision

Servers List

You would normally define servers to connect to in "kundera.nodes" property under persistence.xml. However, if you have MongoDB servers running on multiple nodes and possibly different ports, This property comes to your rescue. Just specify this in MongoDB XML configuration file (See XML at bottom)

Read Preference

MongoDB lets you choose whether you want to read data from primary or secondary server. You can specify this behaviour in the following way into MongoDB XML configuration file. (See XML at bottom). Possible values are "primary" and "secondary".

Socket Timeout

You can configure socket timeout (in millisecond) for time period in MongoDB XML configuration file, kundera will wait for connection to MongoDB before timing out. (See XML at bottom)

A sample XML configuration file is given below:

<?xml version="1.0" encoding="UTF-8"?>
<clientProperties>
    <datastores>
        <dataStore>
	    <name>mongo</name>
	    <connection>
	        <properties>
	            <property name="read.preference" value="primary"></property>
		    <property name="socket.timeout" value="100000"></property>
	        </properties>
	        <servers>
	            <server>
		        <host>192.168.145.168</host>
		        <port>27017</port>
		    </server>
	            <server>
		        <host>192.168.145.167</host>
		        <port>27018</port>
		    </server>
	        </servers>
	    </connection>
        </dataStore>
    </datastores>
</clientProperties>

For a detailed list of property settings available with MongoDb (supported by Kundera ) please refer to : https://github.com/impetus-opensource/Kundera/blob/9f7cd186965704d50c01f9c84fc166ff295d9fd5/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBConstants.java

<<< Back to Datastore Specific Configuration

Home

Clone this wiki locally