The short answer here is yes, if everything is configured correctly then the cache will enlist in the transaction and you will see the guarantees you expect.
Â
The main complication here is that due to the limitations (or scope, depending on your viewpoint) of the JTA spec there is a small amount of wiring necessary to connect the transaction manager to the cache. Ehcache 3.0 comes with wiring for Bitronix (in Java EE), and Narayana (in Jakarta EE) out of the box, anything else is left to the user to handle.
Â
A very short explanation of why this works (although I’m far from a JTA/Spring/JDBC expert).
Â
Precondition: Everyone is retrieving a reference to the same JTA TransactionManager, via whatever lookup mechanism is in place (often JNDI).
Â
That’s basically it. The reason that extra wiring is needed is because the JTA spec is not sufficient to cover all (or really any interesting) recovery scenarios. This means each TM handles registration for recovery purposes differently, and so additional wiring must be done. Transaction managers typically handle this out-of-the-box for JDBC and other common things like that. Ehcache caches must go it alone, because they’re a little more unconventional.
Â
Chris
Disclaimer: This message and files transmitted with it are confidential, intended solely for the use of the individual or entity to whom they are addressed. If you have received this in error, please notify us immediately and delete it with any attachments.
--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
ehcache-user...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ehcache-users/bd508a16-9e78-4ac0-a1e7-f5e4ec8805f9n%40googlegroups.com.
If the cache is also configured as transactional then yes. If  the cache is transactional then it will complain if there is no started transaction when you go to interact with the cache for either write or read. If you get something wrong you’re likely to see the Cache complain about there being no transaction context. Basic documentation can be found here: https://www.ehcache.org/documentation/3.10/xa.html
Â
Good Luck!
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/ef25a499-94b2-44d7-942b-c6ff54864815n%40googlegroups.com.
Yes, that is the case. Spring will handle the begin, commit, and rollback (if it is necessary) and it should also handle the lifecycling of the transaction manager (the shutdown). The only thing you have to do is make sure that Spring and Ehcache are seeing the same TransactionManager.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/b941feac-47e3-47c2-813f-bd7172f202cen%40googlegroups.com.