Hibernate version: 3.2.1
JBossCache version: 1.4.1.CR1
My application is really simple and work for all CRUD operations.
I want to configure a second level cache (with JBossCache provider) in asynchronous replication mode.
Hibernate configuration:
- hibernate.cache.provider_class=org.hibernate.cache.OptimisticTreeCacheProvider
- objects are cached in transactional mode (<class...><cache usage="transactional"/>...</class>)
- queries are cached (q.setCacheMode(true))
JBossCache configuration:
- OPTIMISTIC NodeLockingScheme
- REPL_ASYNC CacheMode
To test the second level cache operations in clustered environment, I launch two instances of the application on two differents server.
I also trace the real SQL operations with P6spy so I can see when the datasource or cache is used.
I can see via the JMX console that the two caches are replicated. So if I execute a query on ServerA, I can see the corresponding nodes (entities and query) on the ServerA and the ServerB caches.
If I re-execute the same query on ServerA, the results in cache are used by Hibernate, instead of database, so it's correct.
But if I execute the same query on ServerB, Hibernate doesn't use the result in cache but execute SQL query on database. (The operation is correct the next time.)
After an update (not already delete beacause of the problem here :
http://forum.hibernate.org/viewtopic.php?t=969417&sid=a4a053a879cf63d141dcabebb344a2d4) on a persistant object, the two queries which contain the object as a part of the result are invalidated, so the process is correct.
So the clustered cache contains two nodes of every query executed both sides. The behaviour seems is like an invalidation mode where every cache is different. Only delete and update operations prevents the other cache(s) to invalid the object if it's already loaded. Hibernate doesn't profit of the replication.
Can somebody confirm that it's not a configuration problem ?
Is it a normal way of the process ?
Rudy KROL