Search code examples
javaspringtransactionsjta

Does Spring JtaTransactionManager automatically omit non-used resources per transactions from Two-Phase Commit?


I'm wondering how Spring enlists resources for a given annotated transaction. Say I have 3 XA enabled datasources D1, D2 and D3. At some times transactions might occur between D1 and D2, at other times, it might occur between D2 and D3, sometimes all datasources (and all combinations...etc.).

So, will Spring automatically enlist only the required resources for a given transaction if all three datasources have been attached to a single JtaTransactionManager instance? If not, must I create multiple instances of JtaTransactionManager per combination of resource enlistment?

Thanks,

Chris

P.S. I have a non-Spring follow up question to this but I'll post separately.


Solution

  • As far as I know, Spring does not care about the XA but is just handling the XA TX manager as a generic JTA manager. So its up to the manager to do it's work when getting committed / rolled back. Spring does just ensure the call is done. That's done by the same proxy implementation that is used by any other Spring TA proxy.