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:
-context.xml and the following content into the
WEB-INF/config/ipp/spring folder of your WAR file:
<?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>WEB-INF/lib of
your WAR file:
hazelcast-2.4.jar (
https://infinity.sungard.com/repository/ipp-3rd-party/com/hazelcast/hazelcast/2.4-stardust03/hazelcast-2.4-stardust03.jar )hazelcast-ra-2.4-stardust03.rar (download from
https://infinity.sungard.com/repository/ipp-3rd-party/com/hazelcast/hazelcast-ra/2.4-stardust03/hazelcast-ra-2.4-stardust03.rar)
carnot.properties
file to enable the Spring-based version of the Hazelcast Cache Factory:
Carnot.Engine.Hazelcast.JcaConnectionFactoryProvider = org.eclipse.stardust.engine.spring.integration.jca.SpringAppContextHazelcastJcaConnectionFactoryProvider
carnot.properties file to
enable Hazelcast caching:
Infinity.Engine.Caching = true
Infinity.Engine.Caching.CacheFactory = org.eclipse.stardust.engine.core.cache.hazelcast.HazelcastCacheFactory
Infinity.Engine.Caching.Hazelcast.TxMode = rw
Infinity.Engine.Caching.Hazelcast.ConnectionFactoryJndiName = HazelcastCF
Infinity.Engine.Caching.Hazelcast.GlobalCacheName = ipp-2nd-level-cache
hazelcast.xml into WEB-INF/classes
folder of your WAR (or a default configuration will be taken from com.hazelcast:hazelcast:2.4).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>