Are XA / JTA transactions used?

I have an application that interacts with several databases and some custom services. For some operations, I need transactional behavior when a set of changes is either fixed in all databases / services, or all are rolled back if an error occurs.

The XA standard from the X / Open group and the Java JTA seem to solve this problem exactly using a two-phase commit process. Some databases (mySQL, Postgres, Oracle) support these interfaces, but I feel that they are not often used or are declining in popularity. It's true? And if so, why?

I know some replication issues from XA to mySQL. In addition, XA transactions can be significantly slower. Are there other reasons why XA is unpopular / unusual?

+4
source share
2 answers

There are several points with XA:

  • He is doing his job, and there is no acceptable alternative. If you must use distributed transactions, then XA does not exist.
  • This is "standard technology", without advertising and marketing. Therefore, it flies below the radars of most people.
  • Even when it is used, there is a good chance that Jack Application Developer does not know this, since most parts are usually hidden in some frameworks.
  • The need for XA does indeed decrease slightly, because service-oriented architecture (SOA) and message ordering are bloated architecture paradigms that try to avoid such tough interactions between subsystems. Although, at least, SOA also seems to be falling pretty well. -)
  • Often forgotten parts of XA are the necessary code and tools that are used when a transaction really breaks. There are some margins in XA where the Transaction Manager can neither commit nor roll back all resources for quite some time. This moment only increases the "use it only if you really should" indicate.
+6
source

They are still used for what you mentioned. If the operation in one of the databases failed, all this is a rollback.

They are slower, therefore, if XA is not required (i.e. it is an autonomous operation or not transactional), then it should not be used.

A Java EE container can even force you to use an XA data source when working with multiple databases.

+1
source

Source: https://habr.com/ru/post/1385192/


All Articles