Search code examples
springhibernatedatasourcejtaxa

When do I use XA datasource and 2 phase commit


Can someone please explain the use of XA dataSource and how transaction management works in an XA datasource ? How is XA datasouce and 2 Phase commit related?


Solution

  • Two-phase commit and XA are more or less synonyms. They ensure that the ACIDity of a transaction is preserved even if this transaction involves several transactional systems such as, for example

    • two databases
    • a database and a JMS engine

    To be able to participate in such a global transaction, each datasource must collaborate with the XA transaction manager, and must thus implement the XA protocol. If you need two-phase commit, you thus need an XA datasource.