Reputation: 188
How we can configure cache in jboss eap 6.3 server and use it in further different application like j2ee etc
Please assist here .. !!
Upvotes: 0
Views: 2852
Reputation: 188
Caching using jboss eap configuration:
Steps
1) subsystem inside standalone-ha.xml of jboss eap 6.3
<subsystem xmlns="urn:jboss:domain:infinispan:1.5">
<cache-container name="DataCacheContainer" aliases="demo" default-cache="EdgeCache" start="EAGER" module="org.jboss.as.clustering.infinispan">
<transport lock-timeout="60000"/>
<replicated-cache name="EdgeCache" mode="ASYNC" batching="true">
<eviction strategy="LRU" max-entries="250000"/>
<file-store/>
</replicated-cache>
<replicated-cache name="SubdivCache" mode="SYNC" batching="true">
<eviction strategy="LIRS" max-entries="25000"/>
<file-store/>
</replicated-cache>
</cache-container>
<cache-container name="LocatorCacheContainer" default-cache="trainLocatorCache">
<local-cache name="LocatorCache"/>
</cache-container>
<cache-container name="ScheduleCacheContainer" default-cache="tgeoControlPtCache">
<local-cache name="ControlPtCache"/>
</cache-container>
<cache-container name="singleton" aliases="cluster ha-partition" default-cache="default">
<transport lock-timeout="60000"/>
<replicated-cache name="default" mode="SYNC" batching="true">
<locking isolation="REPEATABLE_READ"/>
</replicated-cache>
</cache-container>
<cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
<transport lock-timeout="60000"/>
<replicated-cache name="repl" mode="ASYNC" batching="true">
<file-store/>
</replicated-cache>
<replicated-cache name="sso" mode="SYNC" batching="true"/>
<distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
<file-store/>
</distributed-cache>
</cache-container>
<cache-container name="ejb" aliases="sfsb sfsb-cache" default-cache="repl" module="org.jboss.as.clustering.ejb3.infinispan">
<transport lock-timeout="60000"/>
<replicated-cache name="repl" mode="ASYNC" batching="true">
<eviction strategy="LRU" max-entries="10000"/>
<file-store/>
</replicated-cache>
<replicated-cache name="remote-connector-client-mappings" mode="SYNC" batching="true"/>
<distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
<eviction strategy="LRU" max-entries="10000"/>
<file-store/>
</distributed-cache>
</cache-container>
2) Lookup of these cache container from code using url:
private static Cache<Integer, DataObject> cache;
private static Cache<String, Integer> DivCache;
InitialContext ic = new InitialContext();
CacheContainer cc = (CacheContainer) ic.lookup("java:jboss/infinispan/container/DataCacheContainer");
cc.start();
cache = cc.getCache("EdgeCache");
divCache = cc.getCache("SubDivCache");
cache.start();
divCache.start();
logger.info("Cache Objects started successfully...");
3) Now you can store data in these cache objects.
cache.put("one", "two"); divCache.put("three","four");
Upvotes: 2
Reputation: 188
Hi I did "Caching with Infinispan in Jboss EAP 6.3"
Below are steps for same-
If your project is maven project add one dependency into pom.xml whatever version you needed like-
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>7.1.0.Final</version>
</dependency>
3.Create sample class in your project and inside that add this code snippet-
Cache<String, String> userInputCache;
EmbeddedCacheManager cm = new DefaultCacheManager("infinispan.xml");
userInputCache = cm.getCache("demoClusterCache");
userInputCache.put("demo", "DemoCacheValue");
System.out.println("cache value is :+ userInputCache.get("demo"));
4.Now need to add this "userInputCache into your infinispan.xml" file below is the code for same-
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:7.1 http://www.infinispan.org/schemas/infinispan-config-7.1.xsd"
xmlns="urn:infinispan:config:7.1">
<jgroups>
<stack-file name="udp" path="jgroups.xml" />
</jgroups>
<cache-container default-cache="default" >
<transport stack="udp" node-name="demo" />
<replicated-cache name="repl" mode="SYNC" />
<distributed-cache name="dist" mode="SYNC" owners="2" />
<local-cache name="demoClusterCache">
<eviction strategy="LIRS" max-entries="10" />
</local-cache>
</cache-container>
</infinispan>
5.Here we have jgroups.xml file also if you need to configure this caching over distributed and clustered environment then need to add this also below is the code for same-
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.4.xsd">
<!--
Note that the buffer sizes here are very small, you'll definitely want higher values in production.
But the Linux defaults are also very small, and using higher values here without changing the system
settings would only result in startup warnings.14.96.226.125
-->
<UDP
mcast_addr="${jgroups.udp.mcast_addr:228.8.8.8}"
mcast_port="${jgroups.udp.mcast_port:45566}"
tos="8"
ucast_recv_buf_size="200k"
ucast_send_buf_size="200k"
mcast_recv_buf_size="200k"
mcast_send_buf_size="200k"
loopback="true"
max_bundle_size="64000"
max_bundle_timeout="30"
ip_ttl="${jgroups.udp.ip_ttl:2}"
enable_bundling="true"
enable_diagnostics="false"
bundler_type="old"
thread_naming_pattern="pl"
thread_pool.enabled="true"
thread_pool.min_threads="2"
thread_pool.max_threads="30"
thread_pool.keep_alive_time="60000"
thread_pool.queue_enabled="true"
thread_pool.queue_max_size="100"
thread_pool.rejection_policy="Discard"
oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="2"
oob_thread_pool.max_threads="30"
oob_thread_pool.keep_alive_time="60000"
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="Discard"
/>
<PING timeout="3000" num_initial_members="3"/>
<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
<FD_ALL timeout="15000"/>
<VERIFY_SUSPECT timeout="5000"/>
<!-- Commented when upgraded to 3.1.0.Alpha (remove eventually)
<pbcast.NAKACK exponential_backoff="0"
use_mcast_xmit="true"
retransmit_timeout="300,600,1200"
discard_delivered_msgs="true"/> -->
<pbcast.NAKACK2
xmit_interval="1000"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="10000"
xmit_table_max_compaction_time="10000"
max_msg_batch_size="100"/>
<!-- Commented when upgraded to 3.1.0.Alpha (remove eventually)
<UNICAST timeout="300,600,1200"/> -->
<UNICAST2
stable_interval="5000"
xmit_interval="500"
max_bytes="1m"
xmit_table_num_rows="20"
xmit_table_msgs_per_row="10000"
xmit_table_max_compaction_time="10000"
max_msg_batch_size="100"
conn_expiry_timeout="0"/>
<pbcast.STABLE stability_delay="500" desired_avg_gossip="5000" max_bytes="1m"/>
<pbcast.GMS print_local_addr="false" join_timeout="3000" view_bundling="true"/>
<UFC max_credits="200k" min_threshold="0.20"/>
<MFC max_credits="200k" min_threshold="0.20"/>
<FRAG2 frag_size="8000" />
<RSVP timeout="60000" resend_interval="500" ack_on_delivery="true" />
</config>
6.Execute your first sample class you have cached data - Good luck
Upvotes: 1