With version 2.1, Hazelcast will support MongoDB persistence integrated with Spring Data-MongoDB module. Spring MongoDB module maps your objects to equivalent MongoDB objects. To persist your objects into MongoDB you should define MongoDB mapstore in your Spring configuration as follows:
<mongo:mongo id="mongo" host="localhost" port="27017"/> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg name="databaseName" value="test"/> </bean> <bean class="com.hazelcast.spring.mongodb.MongoMapStore" id="mongomapstore"> <property name="mongoTemplate" ref="mongoTemplate" /> </bean>
Then you can set this as mapstore for maps that you want to persist into MongoDB.
<hz:map name="user"> <hz:map-store enabled="true" implementation="mongomapstore" write-delay-seconds="0"> </hz:map-store> </hz:map>
By default, the key is set as id of the MongoDB object. You can override MongoMapStore class for you custom needs. For more info see Spring Data MongoDB Reference .