Steps to configure infinispan
1) declare cache container(infinispan),locking strategy,related extension(jgroups) in standalone.xml
a)eg:
<cache-container name="testcache" default-cache="default" module="org.wildfly.clustering.server">
<transport lock-timeout="60000"/>
<replicated-cache name="default" mode="SYNC">
<locking isolation="REPEATABLE_READ"/>
</replicated-cache>
</cache-container>
b)
<extension module="org.jboss.as.clustering.jgroups"/>
c)
<subsystem xmlns="urn:jboss:domain:jgroups:3.0">
<channels default="ee">
<channel name="ee"/>
</channels>
<stacks default="tcp">
<stack name="tcp">
<transport type="TCP" socket-binding="jgroups-tcp"/>
<protocol type="MPING" socket-binding="jgroups-mping"/>
<protocol type="MERGE3"/>
<protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
<protocol type="FD"/>
<protocol type="VERIFY_SUSPECT"/>
<protocol type="pbcast.NAKACK2"/>
<protocol type="UNICAST3"/>
<protocol type="pbcast.STABLE"/>
<protocol type="pbcast.GMS"/>
<protocol type="MFC"/>
<protocol type="FRAG2"/>
<protocol type="RSVP"/>
</stack>
</stacks>
</subsystem>
d)
<interface name="jgroups">
<inet-address value="127.0.0.1"/>
</interface>
e)
<socket-binding name="jgroups-mping" interface="jgroups" port="0" multicast-address="230.0.0.4" multicast-port="45700"/>
<socket-binding name="jgroups-tcp" interface="jgroups" port="7600"/>
<socket-binding name="jgroups-tcp-fd" interface="jgroups" port="57600"/>
2)include infinispan dependency in maven file
a)eg:
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>7.2.3.Final</version>
<scope>provided</scope>
</dependency>
b)add dependency in manifest of jar using infinispan(requires explicit referencing of dependency)
<Dependencies>org.infinispan</Dependencies>
3)use the above cache container declared in session beans
a) eg:
@Resource(lookup="java:jboss/infinispan/container/testcache")
private CacheContainer container;
b)
private Cache<String,Map<String, LoginVO>> testCache;
c)
@PostConstruct
public void initCache(){
testCache=container.getCache();
}
Comments