-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Jboss cache replicates no changes when used from Hibernate
PostPosted: Wed Mar 17, 2010 6:37 am 
Newbie

Joined: Wed Mar 17, 2010 6:35 am
Posts: 3
We are using jboss cache as second level hibernate cache. It is configured to evict changed entities asyncronously. But this feature does not work for us. Some debugging revealed the root of the problem.

When treecache accessed, it adds itself as transaction listener. This is done by adding Synchronization to active transaction inside org.jboss.cache.interceptors.OrderedSynchronizationHandler (see getInstance() method). Hibernate adds itself too when session created.

In usual case ejb access to entities from hibernate first, and then hibernate accesses tree cache as its own L2 cache. So hibernate sync registered first and tree cache registered second.

In our case first accessed tree cache for storing information about ejb calls, and only after that hibernate session created. So tree cache sync became first. It does not matter that availability tree cache is not hibernate tree cache -- they both are using same synch (see OrderedSynchronizationHandler.getInstance implementation).

So when transaction committed, tree cache synch called first. And here comes to play tree cache configuration quality -- if async replication or invalidation used, cache triggers it on transaction prepare phase -- i.e. in beforeComplete method of Sync. But as hibernate sync placed after tree cache's sync, it had no chance to see any changes to replicate. And in beforeComplete method tree cache replicates no changes!

The current solution for us -- place working with tree cache to separate transaction. But this solution need programmers to remember about placing some tree cache calls into separate transaction.

Does anybody faced this problem too? Is there another solution?


Top
 Profile  
 
 Post subject: Re: Jboss cache replicates no changes when used from Hibernate
PostPosted: Wed Mar 17, 2010 6:44 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Do you use JTA approach or plain JDBCTransactionFactory in Hibernate configuration?
(Be aware of the fact that JbossCache as 2L cache for Hibernate requires integration with JTA)


Top
 Profile  
 
 Post subject: Re: Jboss cache replicates no changes when used from Hibernate
PostPosted: Wed Mar 17, 2010 7:12 am 
Newbie

Joined: Wed Mar 17, 2010 6:35 am
Posts: 3
JTA integration is used. Actually replication works fine, if availability tree cache used from separate transaction.


Top
 Profile  
 
 Post subject: Re: Jboss cache replicates no changes when used from Hibernate
PostPosted: Wed Mar 17, 2010 7:26 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Is there another solution?


I would try migrate to Infinispan which is the successor of JBossCache.
Maybe there the problem does not exist (and Infinispan should be faster than JBossCache )


Top
 Profile  
 
 Post subject: Re: Jboss cache replicates no changes when used from Hibernate
PostPosted: Wed Mar 17, 2010 7:41 am 
Newbie

Joined: Wed Mar 17, 2010 6:35 am
Posts: 3
Actually our team tied to old JBoss version (4.2), where AFAIK Infinispan is not available


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.