tags:

views:

17

answers:

2

I have an administrative page in a web application that resets the cache, but it only resets the cache on the current JVM.

The web application is deployed as a cluster to two WAS servers.

Any way that I can elegantly have the "clear cache" button on each server trigger the method on both JVMs?

Edit: The original developer just wrote a singleton holding a HashMap to be the cache in question. Lightweight and (previously) worked just fine for the requirements. It caches content pulled from six or seven web services for specified amounts of time.

Edit: The entire application in question is three pages, so the elegant solution might well be the lightest solution.

+1  A: 

I tend to use a JMS queue for doing exactly that.

Quotidian
+1  A: 

Since the Cache is internal to your application you are going to need to provide an interface to clear it within your application. Quotidian says to use a JMS queue. That will not work because only one instance will pick up the message assuming you have clustered MQ Queues.

If you want to reuse the same implementation then the only way to do this is to write some JMX that you will be able to interact with at the instance level.

If not you can either use the built in WAS cache (which is JMX enabled) or use a distributed cache like ehcache.

in the past I have created a subclassed LinkedHashMap that was linked to all instances on the network using JBOSS JGroups. Of course reinventing the wheel is always painful.

Romain Hippeau