Reputation: 6802
I have an application that interacts multiple databases and some custom services. For some operations, I need transaction-like behavior where a set of changes either commit across all databases/services or all roll back if an error occurs.
The XA standard from the X/Open group and the Java JTA seem to solve exactly this problem using a two-phase commit process. Some databases (mySQL, Postgres, Oracle) support these interfaces, but I get the feeling that they are not often used or declining in popularity. Is that true? And If so, why?
I know there were some replication-related issues with XA on mySQL. Also, XA transactions can be significantly slower. Are there any other reasons why XA is unpopular / uncommon?
Upvotes: 6
Views: 4292
Reputation: 66263
There are several point with XA:
Upvotes: 9
Reputation: 381
They are still used for exactly what you have mentioned. If an operation on one of the databases fails then it all gets rolled back.
They are slower, and so if XA is not needed (i.e. it's an autonomous operation or non-transactional), then it should not be used.
The Java EE container may even force you to use an XA datasource when dealing with multiple DBs.
Upvotes: 1