This chapter describes the Spring configuration required to setup Hazelcast in-memory cache in Spring-managed environments. Hazelcast is a clustering and scalable data distribution platform. For detailed information on Hazelcast refer to http://www.hazelcast.com/product.jsp.
For details on tuning via an in-memory cache in Stardust refer to chapter Retrieving Entities from In-Memory Cache in the Developer Handbook.
The in-memory cache is turned on by default with the property below in your server-side carnot.properties file.
Infinity.Engine.Caching = true
If not, set this property explicitly.
Perform the following steps to prepare a Spring deployment with Hazelcast integration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="localHazelcastConnectionFactory" class="org.springframework.jca.support.LocalConnectionFactoryBean">
<property name="managedConnectionFactory" ref="managedConnectionFactory" />
<property name="connectionManager">
<bean id="connectionManagerFactory" class="org.jencks.factory.ConnectionManagerFactoryBean">
<property name="transactionManager" ref="JencksXaTxManager" />
<property name="transaction" value="xa" />
<property name="poolingSupport" ref="hzPoolingSupport" />
</bean>
</property>
</bean>
<bean id="managedConnectionFactory" class="com.hazelcast.jca.ManagedConnectionFactoryImpl">
<property name="connectionTracingEvents" value="" />
<property name="connectionTracingDetail" value="false" />
<property name="resourceAdapter" ref="resourceAdapter" />
</bean>
<bean id="resourceAdapter" class="com.hazelcast.jca.ResourceAdapterImpl" init-method="start" destroy-method="stop" />
<bean id="hzPoolingSupport" class="org.jencks.factory.PoolingSupportFactoryBean">
<property name="poolMinSize" value="50" />
<property name="poolMaxSize" value="100" />
<property name="connectionMaxWaitMilliseconds" value="5000" />
<property name="connectionMaxIdleMinutes" value="1" />
</bean>
<bean name="JencksXaTxManager" class="org.jencks.factory.TransactionManagerFactoryBean" />
<bean name="springContextPostProcessor" class="org.eclipse.stardust.engine.spring.integration.jca.SpringContextPostProcessor" />
</beans>Carnot.Engine.Hazelcast.JcaConnectionFactoryProvider = org.eclipse.stardust.engine.spring.integration.jca.SpringAppContextHazelcastJcaConnectionFactoryProvider
Create the following default configuration template hazelcast.xml defining one Stardust specific distributed cache object ipp-2nd-level-cache:
The engine then uses Hazelcast as second level cache provider. Add the configuration file to your runtime's classpath.
In case you use Hazelcast in non-clustered environments, e.g. in different environments in the same network, adjust your hazelcast.xml in one of the following ways:
...
<join>
<aws enabled="false" />
<multicast enabled="false" />
<tcp-ip enabled="false" />
</join>
<interfaces>
<interface>127.0.0.1</interface>
</interfaces>
</network>
...
<group>
<name>dev</name>
<password>dev-pass</password>
</group>