Hi,
I have to implement a test application for the following scenario:
1. We have several replicated JBoss Caches on different nodes
2. An Eventpublisher saves events into the cache by (randomly) selecting one of the available Caches
3. If one Cache Node fails, one of the other nodes should be used by the Eventpublisher instead
4. There is no local Cache running on the node of the Eventpublisher
My Question is now: How do I find a Cache when I don't have a local Cache that is in the same Cluster? Is there some kind of lookup mechansim for a "normal" Java program?
I think this might work with Clusters deployed as MBeans in JBoss. I have found some sample code that does a lookup:
try {
MBeanServer server = MBeanServerLocator.locate();
TreeCacheMBean remoteCache = (TreeCacheMBean) MBeanProxyExt
.create(TreeCacheMBean.class,
"jboss.cache:service=TreeCache", server);
assertNotNull(remoteCache);
} catch (MalformedObjectNameException e) {
// exception handing
}
But I would prefer a solution withaout a JBoss Server on each Cache node.
Chris
You could use a startup class that starts the TreeCache and binds it in JNDI - then other 'consumer threads' could look this up in JNDI.