-
1. Re: No transactionality in caches
manik May 20, 2008 12:07 PM (in response to jorgemoralespou_2)Are you using optimistic locking? If so, you need a transaction manager.
If not, you can disable the use of transactions either by not registering a TM n your JBC config, or just making sure there isn't a tx already started when you start interacting with the cache (perhaps suspend any ongoing transactions first). -
2. Re: No transactionality in caches
jorgemoralespou_2 May 20, 2008 2:56 PM (in response to jorgemoralespou_2)Why is it needed for optimistic locking? What if it is a single node cluster cache?
Thanks -
3. Re: No transactionality in caches
manik May 21, 2008 4:29 AM (in response to jorgemoralespou_2)Optimistic locking still requires a transaction manager since nodes are versioned and copied into your transaction workspace that you interact with. Changes are then merged back into the main data structure when you commit.
-
4. Re: No transactionality in caches
duncow9000 Jun 2, 2008 7:04 PM (in response to jorgemoralespou_2)The comment above about making sure a transaction hasn't already started intrigues me.
We're using *pessimistic* locking, but we are also using Spring's HibernateTransactionManager (specifically, annotation-based declarative transaction management).
If we are not using HibernateTransactionManager to support optimistic locking, should we still be able to use HibernateTransactionManager with JBoss Cache in a clustered environment, for pessimistic locking? If JBoss Cache throws a ReplicationException, for example, shouldn't HibernateTransactionManager still roll back the transaction?
Because we are seeing ReplicationExceptions and cache inconsistency, even with pessimistic locking and replication sync, I am also wondering if we are on the wrong road entirely by attempting to use JBoss Cache without JTA, even with pessimistic locking.
We are running on
-- Tomcat 6.0.14
-- Spring 2.0.4
-- Hibernate 3.2.5
-- JBoss Cache 1.4.1.SP9
Thanks in advance for any insights. -
5. Re: No transactionality in caches
manik Jun 3, 2008 6:18 AM (in response to jorgemoralespou_2)To participate in transactions, JBC needs a reference to a JTA transaction manager. I'm guessing HibernateTransactionManager is not a Hibernate class at all, but a Spring one? If this is JTA compliant (i.e., implements javax.transaction.TransactionManager) then you can write a transaction manager lookup for it and specify your transaction manager lookup implementation in your JBoss Cache config.
If you need a standalone JTA compliant transaction manager there are several good OSS ones out there, including JBoss Transaction Manager.