We have a requirement to maintain cache in an application which is deployed in JBoss/Wildfly. Other applications deployed in JBoss should be able to access the same cache to put or get operations. Example: Application A: expected to act as Remote Cache Server Application B, C and D, etc: expected to put and get values into the Cache maintained present in application A.
I have tried with configurations (attached) to perform this, but could not see the data put by one application in another application.
Kindly provide a sample configuration for both server and clients like cache.ccf, remote_cache.ccf, web.xml, etc. and Java code example to access the Remote Cache Server and put/get the cache elements.
It would be helpful if you could provide an end to end configuration with a working example Java code to access the same cache across different applications deployed in JBoss. cache.ccf (server)
# Registry used to register and provide the
# IRemoteCacheService service.
registry.host=localhost
registry.port=1102
# call back port to local caches.
jcs.remotecache.serverattributes.servicePort=1102
# rmi socket factory timeout
jcs.remotecache.serverattributes.rmiSocketFactoryTimeoutMillis=5000
# cluster setting
jcs.remotecache.serverattributes.LocalClusterConsistency=true
jcs.remotecache.serverattributes.AllowClusterGet=true
# sets the default aux value for any non configured caches
jcs.default=DC
jcs.default.cacheattributes=org.apache.commons.jcs3.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
cache.ccf (client)
# Remote RMI Cache set up to failover
jcs.auxiliary.RFailover=org.apache.commons.jcs3.auxiliary.remote.RemoteCacheFactory
jcs.auxiliary.RFailover.attributes=org.apache.commons.jcs3.auxiliary.remote.RemoteCacheAttributes
jcs.auxiliary.RFailover.attributes.FailoverServers=localhost:1102
jcs.auxiliary.RFailover.attributes.RemoveUponRemotePut=true
jcs.auxiliary.RFailover.attributes.GetOnly=false
web.xml
<!--to initialize Remote Cache Servlet-->
<servlet>
<servlet-name>JCSRemoteCacheStartupServlet</servlet-name>
<servlet-class>org.apache.commons.jcs3.auxiliary.remote.server.RemoteCacheStartupServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JCSRemoteCacheStartupServlet</servlet-name>
<url-pattern>/jcs</url-pattern>
</servlet-mapping>