The net.sf.ehcache.transaction.TransactionTimeoutException
is one of those unchecked RuntimeExceptions you should take care of if you use ehcache. If this exceptions occurs you must explicitly rollback the ongoing transaction, otherwise all further requests to start an ehcache transaction from within the current thread will fail with another net.sf.ehcache.transaction.TransactionException
as the cache is in an inconsistent state.
I do it like so:
final TransactionController transactionController = cacheManager.getTransactionController(); try { transactionController.begin(); // Do stuff transactionController.commit(); } catch(TransactionTimeoutException e) { // Rollback transaction because cache will be invalid from this point transactionController.rollback(); // Rethrow or handle e in some way } |
No comments yet
Post a Comment