views:

232

answers:

1

Let's say I have a Java webapp deployed on some Application Server with clustering across a few nodes.

In the webapp, we maintain a cache of some values retrieved from the database, stored in-memory as static variables. Whenever a user performs an update in a particular screen, we clear the cache so that the cached values will be retrieved again the next time they are needed.

Now the problem: Since each node in the cluster is running on a separate JVM, how can I clear the cache across all nodes? Basically I want to call a static function on each cluster node. Is there some standard J2EE way to do this, or it depends on the Application Server software?

A: 

On a 'standard' application server like Jboss you could use JMX or Message Beans for that.

oeogijjowefi
Message beans are probably the official J2EE way to do this. Most J2EE servers will have some other proprietary API as well. J2EE may be a little more work to setup and use, but you will probably also get 'extras' like durability and failover.Keep in mind that neither option will be instantaneous, so your application will need to deal with that - this may not be an issue if it just means that users will see out of sync content for a few page loads.
AngerClown