I have a spring project (spring core 3.1.2) configured with Hibernate (hibernate core 4.2.8) and i want to set up Hazelcast as a 2nd level cache. I want to have the cache distributed in P2P, embedded cluster mode (each application instance runs a hazelcast instance on the same machine).
This is my current sessionFactory configuration.
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" scope="singleton">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.myProject.beans" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.database">ORACLE</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<!--enable batch operations-->
<prop key="hibernate.jdbc.batch_size">20</prop>
<prop key="hibernate.order_inserts">true</prop>
<prop key="hibernate.order_updates">true</prop>
<!-- 2nd level cache configuration-->
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastLocalCacheRegionFactory</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
</props>
</property>
</bean>
This configuration seems to work on my local machine as i ran a small test that checks for a 2nd level cache hit.
The question is: What other configurations must I make in order to have the cache distributed among the instances. How are the different machines going to "know about each other"? Also, is there a way to create a test scenario that checks that the cache is indeed distributed among a couple of machines?(ex: launch 2 jvms) An example would be greatly appreciated.
Any other tips or warnings about this configuration are welcome.
Disclaimer: Its the first time I use Hazelcast.
My Hazelcast version is 3.5.4
Thank you!