Wayne Weber - 2009-06-20

If I have 2 app servers, each with 4 webapps using Hibernate and sharing some of the same entities among the webapps, then it seems like setting up distribution could complex. For example, app server #1, webapp #1 must distribute to all the webapps on its own app server (say using RMI) as well as all the webapps on app server #2, is that right?

Is there a way you could set things up so app server #1 web app#1 distributes to the webapps on its own app server, then distributes to just a single on app server #2 and then that web app relays the distribution to the other apps on its own app server? In other words, distribution between app servers is always done between a single designated web app to another single designated web app but then that designated web app relays the replication to the webapps on its own app server.

* * *

Because the above might be complex to configure and maintain (even if it can be done), I am wondering if Ehcache can be configured to do the following when it is setup as a second level cache with Hibernate:

1. Look in the local cache for the item. If not found, go to step 2.
2. Look for the item in the remote Ehcache server. If not found, go to step 3.
3. Get it out of the database.

A write to the database via Hibernate would do the following:

1. Write to the local cache.
2. Write to the remote Ehcache server (possibly asynchronously)
3. Remote cache server distributes the updates to the local cache on other machines (possibly asynchronously)
4. Write to the database

In this way, the local caches will not have to have knowledge of the other local caches, just the remote Ehcache server(s). Distribution would not peer-to-peer but peer-to-server-to-peer. Can this currently be done?

* * *

Any thoughts or feedback appreciated.

Thanks,

Wayne Weber