We all know that (in JTA) two resources cannot participate in one
transaction unless they follow Open/XA distributed transaction protocol
(or a simulation of it using algorithms such as LLR, LRC) which is a 2PC
negotiation between resource and TX manager.
A LinkedList is not an XA resource unless you yourself write a wrapper
around it. The good news is that such a wrapper is already developed and
is very familiar to all of us: JMS ;)
The other approach is to forget about standards and write some callback
methods to receive rollback/commit events and perform relate logic. This
is also supported in both Spring and EJB.
So, as I completely accept Farzad's comments I would like to proposed
these two alternatives too:
1. Put the list contents in a JMS and enjoy full XA support of it.
2. Write some methods and bind them to TX events.
Considering fast and POJO based JMS implementation we already have, I
myself would prefer the first alternative.