Take care of net.sf.ehcache.transaction.TransactionTimeoutException
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
} |
Share This
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...
— Trackback URI
This entry (permalink) was posted on Wednesday, February 15, 2012, at 12:32 pm by Michael, tagged with ehcache, TransactionTimeoutException and categorized in English posts, Java.
The following post could be of some interest: I care., Optimizing web resources with wro4j, Spring and ehcache, Apple’s making me sick…, Grails, Hibernate, Current Session Context, Apache httpd, Tomcat und sendfile, The dangers of Javas ImageIO, Workshops, Rails’ respond_to method, Creating a better PathMatcher for Spring 3, Some random Grails thoughts and tipps
Post a Comment