The Multiple Applications, Concurrent Branches/Pseudo Asynchronous Pattern

The pattern in brief:
Architecture: see Figure 8.3, “Multiple applications layout”
Number of Application Programs: 2 or more
Number of Resource Managers: 1 or more for every Application Program
Number of Branches in the Gloabal Transaction: 1 for every Application Program
Concurrency among Application Programs: yes, subordinate AP creates a new branch and then executes asynchronously

Description

This is a Distributed Transaction Processing pattern introduced by XTA: two or more Application Programs use any set of Resource Manager(s) and perform concurrent operations inside distinct branches of a common XA global transaction. The Resource Manager(s) must support concurrent branches of the same global transaction: this is part of XA standard, but some resource managers might not support it.

The following picture shows an example that can be implemented, for example, using MySQL (or MariaDB) and PostgreSQL. [52]

Figure 8.10. Example of Multiple Applications, Consecutive Calls/Pseudo Synchronous with two Application Programs and two Resource Managers

Example of “Multiple Applications, Consecutive Calls/Pseudo Synchronous” with two Application Programs and two Resource Managers


The pattern can not be implemented using the standard TX Transaction Demarcation interface.

How it works

Figure 8.11. Simplified sequence diagram for the Multiple Applications, Concurrent Branches/Pseudo Asynchronous Pattern

Simplified sequence diagram for the “Multiple Applications, Concurrent Branches/Pseudo Asynchronous” Pattern

The above figure shows the logic necessary to build this type of applications; it's not a formally correct UML sequence diagram (all the XTA objects are in the same lifeline), but it should be clear enough to understand the proper operations sequence:

  • Both the Application Programs perform some some initial steps like: opening a native connection to the Resource Manager, creating a Transaction Manager object, a XA Resource Manager object, a Transaction object and finally enlisting and opening the Resource Manager

  • The first AP, named superior using XA terminology, starts the global transaction

  • The first AP retrieves the XID associated to the global transaction and uses some sort of message passing to send the XID to the second AP

  • The second AP, named subordinate using XA terminology, branches the global transaction and send back an acknowledge message to the first AP: this is helpful because the superior AP must not start its commit before subordinate branch creation

  • Since then now, the Application Programs can proceed asynchronously with the subsequent operations, specifically using the Resource Managers and committing the distinct branches

  • The last operations are related to clean-up

Note

The dashed red rectangle highlights the XA global transaction.

Important

These are the relevant elements of this pattern:

  • it's designed for a peer to peer approach with some sort of message passing communication protocol in place; it's not strictly asynchronous because there are a couple of synchronization points

  • the first synchronization point is represented by the XID sent from the superior AP to the subordinate AP; the acknowledge message is not strictly necessary, but the first AP must not call tx.Commit() before the second AP completed tx.Branch(xid); conversely, second AP gets a warning because the branch can't be created

  • the second synchronization point is implicit in tx.Commit(): it's a blocking call and all the branches are silently synchronized by the LIXA state server

  • even if there are two synchronization points, the Application Programs can really operate concurrently on their Resource Managers and this aspect can allow faster transactions in comparison with the pattern described in the section called “The Multiple Applications, Concurrent Branches/Pseudo Synchronous Pattern”

  • the diagram shows an example with two Application Programs, but the pattern can be applied to any number of Application Programs in different ways: a subordinate AP can become a superior AP of a called subordinate AP and so on or the superior AP can trigger many subordinate APs

  • the diagram shows an example with only one Resource Manager for every Application Program, but there's no restriction on LIXA and XTA side, on the number of Resource Managers used by an Application Program

Known limitations

Note

Not all the Resource Managers have implemented the XA specifications in the same way. This section tracks some limitations that have been reported by the LIXA project.

Oracle JDBC thin optimizations

As described in Oracle's official documentation [53] at paragraph 30-15 Oracle XA Optimizations, Oracle JDBC implements additional logic, in comparison with the XA specifications, when two ore more branches of the same global transaction are related to the same Oracle Database instance.

Important

In the event that both AP1 and AP2 use the same Oracle Database instance strange behaviors could be reported. Furthermore, one of the calls to rm.doSomething() from AP1 or AP2 could fail as described in this case documented by Red hat, with error ORA-02051: another session or branch in same transaction failed or finalized. A relevant hypotesis described in the case is Oracle seems to disallow attempt to execute SQL on a transaction branch when another branch in the same global transaction has already prepared its transaction.

On the other hand, no such limitation has been found in the Oracle OCI interface for C and C++.

An example using the C language

The supplied examples (example_xta_macbpa01.c and example_xta_macbpa02.c) use PostgreSQL in the role of Resource Manager 2 and MySQL (or MariaDB) in the role of Resource Manager 1; please refer to the instructions explained:

Both programs must be used to execute the example: example_xta_macbpa01 in the role of the superior Application Program (first AP) and example_xta_macbpa02 in the role of the subordinate Application Program (second AP).

Create a working directory in a place you are comfortable with:

[Shell terminal session]
tiian@ubuntu1404-64:~$ cd
tiian@ubuntu1404-64:~$ mkdir tmp
tiian@ubuntu1404-64:~$ cd tmp
tiian@ubuntu1404-64:~/tmp$ 
	  

Copy files example_xta_macbas01.c and example_xta_macbpa02.c in your working dir:

[Shell terminal session]
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/example_xta_macbpa01.c .
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/example_xta_macbpa02.c .
	  

Substitute X.Y.Z with the actual version of the software you installed.

Compile and link the C example programs:

[Shell terminal session]
tiian@ubuntu1404-64:~/tmp$ . /opt/lixa/bin/lixa_env.sh
tiian@ubuntu1404-64:~/tmp$ gcc example_xta_macbpa01.c $(lixa-config -x -c -f -l -d) $(mysql_config --libs_r) -o example_xta_macbpa01
tiian@ubuntu1404-64:~/tmp$ gcc example_xta_macbpa02.c $(lixa-config -x -c -f -l -d) -lpq -o example_xta_macbpa02
	  

If the previous steps worked for you, you should have two executable files of name example_xta_macbpa01 and example_xta_macbpa02 in your current directory:

[Shell terminal session]
tiian@ubuntu1404-64:~/tmp$ ls -l
total 96
-rwxrwxr-x 1 tiian tiian 18599 apr 11 22:52 example_xta_macbpa01
-rw-r--r-- 1 tiian tiian 10387 apr 11 22:52 example_xta_macbpa01.c
-rwxrwxr-x 1 tiian tiian 18525 apr 11 22:52 example_xta_macbpa02
-rw-r--r-- 1 tiian tiian 10537 apr 11 22:52 example_xta_macbpa02.c
	  

The example programs accept four arguments:

  • commit (or rollback): use 1 if you want to perform a global commit or 0 if you want to perform a global rollback

  • insert (or delete): use 1 if you want to insert rows in databases or 0 if you want to delete rows from databases

  • name of the FIFO (named pipe) that will be used to send messages from the superior AP to the subordinate AP

  • name of the FIFO (named pipe) that will be used to return messages from the subordinate AP to the superior AP

Open four terminal sessions: two for the example programs execution,

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ls -l example_xta_macbpa01
-rwxrwxr-x 1 tiian tiian 18599 apr 11 22:52 example_xta_macbpa01
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ls -l example_xta_macbpa02
-rwxrwxr-x 1 tiian tiian 18525 apr 11 22:52 example_xta_macbpa02
	  

one for MySQL queries,

[Shell terminal session - MySQL]
tiian@ubuntu1404-64:~$ mysql -h localhost -u lixa lixa
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.59-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
	  

and one for PostgreSQL queries

[Shell terminal session - PostgreSQL]
tiian@ubuntu1404-64:~$ psql testdb
psql (9.3.22)
Type "help" for help.

testdb=>
	  

Set LIXA_PROFILE environment variable to XTA_DYN, a profile without static Resource Managers defined in lixac_conf.xml:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

create two named pipes (FIFO) to support communication between superior and subordinate Application Programs

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ mkfifo sup2sub
tiian@ubuntu1404-64:~/tmp$ mkfifo sub2sup
tiian@ubuntu1404-64:~/tmp$ ls -l su*
prw-rw-r-- 1 tiian tiian 0 apr  8 22:22 sub2sup
prw-rw-r-- 1 tiian tiian 0 apr  8 22:22 sup2sub
	  

execute both the example programs to insert rows in tables and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa01 1 1 sup2sub sub2sup 
Superior AP has created a global transaction with XID '1279875137.23f76e42960242dabbbe0c79d701a710.e107cfeee0661d23da9322f1ee73faba'
Superior AP has sent XID '1279875137.23f76e42960242dabbbe0c79d701a710.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received XID '1279875137.23f76e42960242dabbbe0c79d701a710.e107cfeee0661d234a6a107d45254b67' from subordinate AP
MySQL, executing >INSERT INTO authors VALUES(1919, 'Levi', 'Primo')<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa02 1 1 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.23f76e42960242dabbbe0c79d701a710.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.23f76e42960242dabbbe0c79d701a710.e107cfeee0661d234a6a107d45254b67'
Subordinate AP has sent XID '1279875137.23f76e42960242dabbbe0c79d701a710.e107cfeee0661d234a6a107d45254b67' to superior AP
PostgreSQL, executing >INSERT INTO authors VALUES(1921, 'Rigoni Stern', 'Mario')<
Subordinate AP has committed its branch
	  

Note

The first (superior) Application Program suspends and waits the return value from the second (subordinate) Application Program.

The XID generated by the subordinate AP differs from the XID generated by the superior AP in the last 16 hexadecimal symbols of the branch qualifier; the first 16 hexadecimal symbols are the same: this is not required by XA specification but can be useful for troubleshooting purposes.

Check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows from tables, but rollback:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa01 0 0 sup2sub sub2sup 
Superior AP has created a global transaction with XID '1279875137.110e8d024d1c4137a189c50e005a3432.e107cfeee0661d23da9322f1ee73faba'
Superior AP has sent XID '1279875137.110e8d024d1c4137a189c50e005a3432.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received XID '1279875137.110e8d024d1c4137a189c50e005a3432.e107cfeee0661d238b40227da3dd406d' from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has rolled back its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa02 0 0 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.110e8d024d1c4137a189c50e005a3432.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.110e8d024d1c4137a189c50e005a3432.e107cfeee0661d238b40227da3dd406d'
Subordinate AP has sent XID '1279875137.110e8d024d1c4137a189c50e005a3432.e107cfeee0661d238b40227da3dd406d' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has rolled back its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa01 1 0 sup2sub sub2sup 
Superior AP has created a global transaction with XID '1279875137.2a562ebe33654b4fa3d142569392ab13.e107cfeee0661d23da9322f1ee73faba'
Superior AP has sent XID '1279875137.2a562ebe33654b4fa3d142569392ab13.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received XID '1279875137.2a562ebe33654b4fa3d142569392ab13.e107cfeee0661d2396e0fac5217f44a8' from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa02 1 0 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.2a562ebe33654b4fa3d142569392ab13.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.2a562ebe33654b4fa3d142569392ab13.e107cfeee0661d2396e0fac5217f44a8'
Subordinate AP has sent XID '1279875137.2a562ebe33654b4fa3d142569392ab13.e107cfeee0661d2396e0fac5217f44a8' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has committed its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
Empty set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
(0 rows)

testdb=>
	  

Source Code

Source code for programs example_xta_macbpa01.c and example_xta_macbpa02.c are installed in directory /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta and are available on GitHub. Source code is fully commented for readability.

An example using the C++ language

The supplied examples (example_xta_macbpa11.cpp and example_xta_macbpa12.cpp) use PostgreSQL in the role of Resource Manager 2 and MySQL (or MariaDB) in the role of Resource Manager 1; please refer to the instructions explained:

Both programs must be used to execute the example: example_xta_macbpa11 in the role of the superior Application Program (first AP) and example_xta_macbpa12 in the role of the subordinate Application Program (second AP).

Create a working directory in a place you are comfortable with:

[Shell terminal session]
tiian@ubuntu1404-64:~$ cd
tiian@ubuntu1404-64:~$ mkdir tmp
tiian@ubuntu1404-64:~$ cd tmp
tiian@ubuntu1404-64:~/tmp$ 
	  

Copy files example_xta_macbas11.cpp and example_xta_macbpa12.cpp in your working dir:

[Shell terminal session]
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/cpp/example_xta_macbpa11.cpp .
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/cpp/example_xta_macbpa12.cpp .
	  

Substitute X.Y.Z with the actual version of the software you installed.

Compile and link the C++ example programs:

[Shell terminal session]
tiian@ubuntu1404-64:~/tmp$ . /opt/lixa/bin/lixa_env.sh
tiian@ubuntu1404-64:~/tmp$ g++ example_xta_macbpa11.cpp $(lixa-config -c -f -l -d --xta --language-cpp) $(mysql_config --libs_r) -o example_xta_macbpa11
tiian@ubuntu1404-64:~/tmp$ g++ example_xta_macbpa12.cpp $(lixa-config -c -f -l -d --xta --language-cpp) -lpq -o example_xta_macbpa12
	  

If the previous steps worked for you, you should have two executable files of name example_xta_macbpa11 and example_xta_macbpa12 in your current directory:

[Shell terminal session]
tiian@ubuntu1404-64:~/tmp$ ls -l
total 80
-rwxrwxr-x 1 tiian tiian 26419 ago 30 21:49 example_xta_macbpa11
-rw-r--r-- 1 tiian tiian  8305 ago 30 21:48 example_xta_macbpa11.cpp
-rwxrwxr-x 1 tiian tiian 26342 ago 30 21:49 example_xta_macbpa12
-rw-r--r-- 1 tiian tiian  8614 ago 30 21:49 example_xta_macbpa12.cpp
	  

The example programs accept four arguments:

  • commit (or rollback): use 1 if you want to perform a global commit or 0 if you want to perform a global rollback

  • insert (or delete): use 1 if you want to insert rows in databases or 0 if you want to delete rows from databases

  • name of the FIFO (named pipe) that will be used to send messages from the superior AP to the subordinate AP

  • name of the FIFO (named pipe) that will be used to return messages from the subordinate AP to the superior AP

Open four terminal sessions: two for the example programs execution,

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ls -l example_xta_macbpa11
-rwxrwxr-x 1 tiian tiian 26419 ago 30 21:49 example_xta_macbpa11
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ls -l example_xta_macbpa12
-rwxrwxr-x 1 tiian tiian 26342 ago 30 21:49 example_xta_macbpa12
	  

one for MySQL queries,

[Shell terminal session - MySQL]
tiian@ubuntu1404-64:~$ mysql -h localhost -u lixa lixa
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.61-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
	  

and one for PostgreSQL queries

[Shell terminal session - PostgreSQL]
tiian@ubuntu1404-64:~$ psql testdb
psql (9.3.24)
Type "help" for help.

testdb=>
	  

Set LIXA_PROFILE environment variable to XTA_DYN, a profile without static Resource Managers defined in lixac_conf.xml:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

create two named pipes (FIFO) to support communication between superior and subordinate Application Programs

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ mkfifo sup2sub
tiian@ubuntu1404-64:~/tmp$ mkfifo sub2sup
tiian@ubuntu1404-64:~/tmp$ ls -l su*
prw-rw-r-- 1 tiian tiian 0 ago 30 21:55 sub2sup
prw-rw-r-- 1 tiian tiian 0 ago 30 21:55 sup2sub
	  

execute both the example programs to insert rows in tables and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa11 1 1 sup2sub sub2sup
Superior AP has sent XID '1279875137.5aaef2e493c74a38a4547b446c859b1f.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received '1279875137.5aaef2e493c74a38a4547b446c859b1f.e107cfeee0661d236f20dd6b11f54de1' reply from subordinate AP
MySQL, executing >INSERT INTO authors VALUES(1919, 'Levi', 'Primo')<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa12 1 1 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.5aaef2e493c74a38a4547b446c859b1f.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.5aaef2e493c74a38a4547b446c859b1f.e107cfeee0661d236f20dd6b11f54de1'
Subordinate AP has returned '1279875137.5aaef2e493c74a38a4547b446c859b1f.e107cfeee0661d236f20dd6b11f54de1' to superior AP
PostgreSQL, executing >INSERT INTO authors VALUES(1921, 'Rigoni Stern', 'Mario')<
Subordinate AP has committed its branch
	  

Note

The first (superior) Application Program suspends and waits the return value from the second (subordinate) Application Program.

The XID generated by the subordinate AP differs from the XID generated by the superior AP in the last 16 hexadecimal symbols of the branch qualifier; the first 16 hexadecimal symbols are the same: this is not required by XA specification but can be useful for troubleshooting purposes.

Check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows from tables, but rollback:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa11 0 0 sup2sub sub2sup
Superior AP has sent XID '1279875137.64630ff1b9ed45a9be0d61591fbd0902.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received '1279875137.64630ff1b9ed45a9be0d61591fbd0902.e107cfeee0661d23b3d84907125644fb' reply from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has rolled back its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa12 0 0 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.64630ff1b9ed45a9be0d61591fbd0902.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.64630ff1b9ed45a9be0d61591fbd0902.e107cfeee0661d23b3d84907125644fb'
Subordinate AP has returned '1279875137.64630ff1b9ed45a9be0d61591fbd0902.e107cfeee0661d23b3d84907125644fb' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has rolled back its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa11 1 0 sup2sub sub2sup
Superior AP has sent XID '1279875137.026b900538d1419da4ab8d728519c75d.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received '1279875137.026b900538d1419da4ab8d728519c75d.e107cfeee0661d23158770b81d1b41b5' reply from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ./example_xta_macbpa12 1 0 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.026b900538d1419da4ab8d728519c75d.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.026b900538d1419da4ab8d728519c75d.e107cfeee0661d23158770b81d1b41b5'
Subordinate AP has returned '1279875137.026b900538d1419da4ab8d728519c75d.e107cfeee0661d23158770b81d1b41b5' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has committed its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
Empty set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
(0 rows)

testdb=>
	  

Source Code

Source code for programs example_xta_macbpa11.cpp and example_xta_macbpa12.cpp are installed in directory /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/cpp and are available on GitHub. Source code is fully commented for readability.

An example using the Java language

The supplied examples (ExampleXtaMACBPA31.java and ExampleXtaMACBPA32.java) use PostgreSQL in the role of Resource Manager 2 and MySQL (or MariaDB) in the role of Resource Manager 1; please refer to the instructions explained:

Both programs must be used to execute the example: ExampleXtaMACBPA31.class in the role of the superior Application Program (first AP) and ExampleXtaMACBPA32.java in the role of the subordinate Application Program (second AP).

Create a working directory in a place you are comfortable with:

[Shell terminal session]
tiian@ubuntu1404-64:~$ cd
tiian@ubuntu1404-64:~$ mkdir tmp
tiian@ubuntu1404-64:~$ cd tmp
tiian@ubuntu1404-64:~/tmp$ 
	  

Copy files ExampleXtaMACBPA31.java and ExampleXtaMACBPA32.java in your working dir:

[Shell terminal session]
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/java/ExampleXtaMACBPA31.java .
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/java/ExampleXtaMACBPA32.java .
	  

Substitute X.Y.Z with the actual version of the software you installed.

Use the proper paths for MySQL and PostgreSQL jars, then compile the Java example programs with something like:

[Shell terminal session]
tiian@ubuntu1404-64:~/tmp$ javac -cp /opt/lixa/share/lixa/java/xta.jar:/usr/share/java/mysql.jar ExampleXtaMACBPA31.java
tiian@ubuntu1404-64:~/tmp$ javac -cp /opt/lixa/share/lixa/java/xta.jar:/opt/postgresql/postgresql.jar ExampleXtaMACBPA32.java
	  

If the previous steps worked for you, you should have two class files of name ExampleXtaMACBPA31.class and ExampleXtaMACBPA32.class in your current directory:

[Shell terminal session]
tiian@ubuntu1404-64:~/tmp$ ls -l
total 40
-rw-rw-r-- 1 tiian tiian 4258 gen 16 22:18 ExampleXtaMACBPA31.class
-rw-r--r-- 1 tiian tiian 8624 gen 16 22:17 ExampleXtaMACBPA31.java
-rw-rw-r-- 1 tiian tiian 4449 gen 16 22:18 ExampleXtaMACBPA32.class
-rw-r--r-- 1 tiian tiian 9066 gen 16 22:17 ExampleXtaMACBPA32.java
	  

The example programs accept four arguments:

  • commit (or rollback): use 1 if you want to perform a global commit or 0 if you want to perform a global rollback

  • insert (or delete): use 1 if you want to insert rows in databases or 0 if you want to delete rows from databases

  • name of the FIFO (named pipe) that will be used to send messages from the superior AP to the subordinate AP

  • name of the FIFO (named pipe) that will be used to return messages from the subordinate AP to the superior AP

Open four terminal sessions: two for the example programs execution,

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ls -l ExampleXtaMACBPA31.class
-rw-rw-r-- 1 tiian tiian 4258 gen 16 22:18 ExampleXtaMACBPA31.class
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ls -l ExampleXtaMACBPA32.class
-rw-rw-r-- 1 tiian tiian 4449 gen 16 22:18 ExampleXtaMACBPA32.class
	  

one for MySQL queries,

[Shell terminal session - MySQL]
tiian@ubuntu1404-64:~$ mysql -h localhost -u lixa lixa
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.5.62-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
	  

and one for PostgreSQL queries

[Shell terminal session - PostgreSQL]
tiian@ubuntu1404-64:~$ psql testdb
psql (9.3.24)
Type "help" for help.

testdb=>
	  

Set LIXA_PROFILE environment variable to XTA_DYN, a profile without static Resource Managers defined in lixac_conf.xml:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

create two named pipes (FIFO) to support communication between superior and subordinate Application Programs

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ mkfifo sup2sub
tiian@ubuntu1404-64:~/tmp$ mkfifo sub2sup
tiian@ubuntu1404-64:~/tmp$ ls -l su*
prw-rw-r-- 1 tiian tiian 0 gen 16 22:22 sub2sup
prw-rw-r-- 1 tiian tiian 0 gen 16 22:22 sup2sub
	  

execute both the example programs to insert rows in tables and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ java -Djava.library.path=/opt/lixa/lib -cp /opt/lixa/share/lixa/java/xta.jar:/usr/share/java/mysql.jar:. ExampleXtaMACBPA31 1 1 sup2sub sub2sup
Superior AP has sent XID '1279875137.85f2e53ef31c4935b48b8f3822e34b9f.cd976821ac38611801b6e378a35a3c7a' to subordinate AP
Superior AP has received '1279875137.85f2e53ef31c4935b48b8f3822e34b9f.cd976821ac386118e674e93fa3094bf2' reply from subordinate AP
MySQL, executing >INSERT INTO authors VALUES(1919, 'Levi', 'Primo')<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ java -Djava.library.path=/opt/lixa/lib -cp /opt/lixa/share/lixa/java/xta.jar:/opt/postgresql/postgresql.jar:. ExampleXtaMACBPA32 1 1 sup2sub sub2sup
Subordinate AP has received XID '1279875137.85f2e53ef31c4935b48b8f3822e34b9f.cd976821ac38611801b6e378a35a3c7a' from superior AP
Subordinate AP has created a branch with XID '1279875137.85f2e53ef31c4935b48b8f3822e34b9f.cd976821ac386118e674e93fa3094bf2'
Subordinate AP has returned '1279875137.85f2e53ef31c4935b48b8f3822e34b9f.cd976821ac386118e674e93fa3094bf2' to superior AP
PostgreSQL, executing >INSERT INTO authors VALUES(1921, 'Rigoni Stern', 'Mario')<
Subordinate AP has committed its branch
	  

Note

The first (superior) Application Program suspends and waits the return value from the second (subordinate) Application Program.

The XID generated by the subordinate AP differs from the XID generated by the superior AP in the last 16 hexadecimal symbols of the branch qualifier; the first 16 hexadecimal symbols are the same: this is not required by XA specification but can be useful for troubleshooting purposes.

Check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows from tables, but rollback:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ java -Djava.library.path=/opt/lixa/lib -cp /opt/lixa/share/lixa/java/xta.jar:/usr/share/java/mysql.jar:. ExampleXtaMACBPA31 0 0 sup2sub sub2sup
Superior AP has sent XID '1279875137.82d2f4005de54d1ca7e866a7f9ab41a7.cd976821ac38611801b6e378a35a3c7a' to subordinate AP
Superior AP has received '1279875137.82d2f4005de54d1ca7e866a7f9ab41a7.cd976821ac3861183632123936de4db4' reply from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has rolled back its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ java -Djava.library.path=/opt/lixa/lib -cp /opt/lixa/share/lixa/java/xta.jar:/opt/postgresql/postgresql.jar:. ExampleXtaMACBPA32 0 0 sup2sub sub2sup
Subordinate AP has received XID '1279875137.82d2f4005de54d1ca7e866a7f9ab41a7.cd976821ac38611801b6e378a35a3c7a' from superior AP
Subordinate AP has created a branch with XID '1279875137.82d2f4005de54d1ca7e866a7f9ab41a7.cd976821ac3861183632123936de4db4'
Subordinate AP has returned '1279875137.82d2f4005de54d1ca7e866a7f9ab41a7.cd976821ac3861183632123936de4db4' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has rolled back its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ java -Djava.library.path=/opt/lixa/lib -cp /opt/lixa/share/lixa/java/xta.jar:/usr/share/java/mysql.jar:. ExampleXtaMACBPA31 1 0 sup2sub sub2sup
Superior AP has sent XID '1279875137.c824ea533d30425c920432b56264498d.cd976821ac38611801b6e378a35a3c7a' to subordinate AP
Superior AP has received '1279875137.c824ea533d30425c920432b56264498d.cd976821ac3861184aaf2d887d434551' reply from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ java -Djava.library.path=/opt/lixa/lib -cp /opt/lixa/share/lixa/java/xta.jar:/opt/postgresql/postgresql.jar:. ExampleXtaMACBPA32 1 0 sup2sub sub2sup
Subordinate AP has received XID '1279875137.c824ea533d30425c920432b56264498d.cd976821ac38611801b6e378a35a3c7a' from superior AP
Subordinate AP has created a branch with XID '1279875137.c824ea533d30425c920432b56264498d.cd976821ac3861184aaf2d887d434551'
Subordinate AP has returned '1279875137.c824ea533d30425c920432b56264498d.cd976821ac3861184aaf2d887d434551' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has committed its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
Empty set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
(0 rows)

testdb=>
	  

Source Code

Source code for programs ExampleXtaMACBPA31.java and ExampleXtaMACBPA32.java are installed in directory /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/java and are available on GitHub. Source code is fully commented for readability.

An example using the Python language

The supplied examples (example_xta_macbpa21.py and example_xta_macbpa22.py) use PostgreSQL in the role of Resource Manager 2 and MySQL (or MariaDB) in the role of Resource Manager 1; please refer to the instructions explained:

Both programs must be used to execute the example: example_xta_macbpa21.py in the role of the superior Application Program (first AP) and example_xta_macbpa22.py in the role of the subordinate Application Program (second AP). Python 2 and Python 3 can be used even mixing them: one for the first AP and one for the second AP.

Create a working directory in a place you are comfortable with:

[Shell terminal session]
tiian@ubuntu1404-64:~$ cd
tiian@ubuntu1404-64:~$ mkdir tmp
tiian@ubuntu1404-64:~$ cd tmp
tiian@ubuntu1404-64:~/tmp$ 
	  

Copy files example_xta_macbas21.py and example_xta_macbpa22.py in your working dir:

[Shell terminal session]
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/python/example_xta_macbpa21.py .
tiian@ubuntu:~/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/python/example_xta_macbpa22.py .
	  

Substitute X.Y.Z with the actual version of the software you installed.

The example programs accept four arguments:

  • commit (or rollback): use 1 if you want to perform a global commit or 0 if you want to perform a global rollback

  • insert (or delete): use 1 if you want to insert rows in databases or 0 if you want to delete rows from databases

  • name of the FIFO (named pipe) that will be used to send messages from the superior AP to the subordinate AP

  • name of the FIFO (named pipe) that will be used to return messages from the subordinate AP to the superior AP

Open four terminal sessions: two for the example programs execution,

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ ls -l example_xta_macbpa21.py 
-rw-r--r-- 1 tiian tiian 4595 ott 15 22:51 example_xta_macbpa21.py
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ ls -l example_xta_macbpa22.py 
-rw-r--r-- 1 tiian tiian 4643 ott 15 22:52 example_xta_macbpa22.py
	  

one for MySQL queries,

[Shell terminal session - MySQL]
tiian@ubuntu1404-64:~$ mysql -h localhost -u lixa lixa
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.61-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
	  

and one for PostgreSQL queries

[Shell terminal session - PostgreSQL]
tiian@ubuntu1404-64:~$ psql testdb
psql (9.3.24)
Type "help" for help.

testdb=>
	  

Set LIXA_PROFILE environment variable to XTA_DYN, a profile without static Resource Managers defined in lixac_conf.xml:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ export LIXA_PROFILE=XTA_DYN
tiian@ubuntu1404-64:~/tmp$ echo $LIXA_PROFILE
XTA_DYN
	  

create two named pipes (FIFO) to support communication between superior and subordinate Application Programs

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ mkfifo sub2sup
tiian@ubuntu1404-64:~/tmp$ mkfifo sup2sub
tiian@ubuntu1404-64:~/tmp$ ls -l su*
prw-rw-r-- 1 tiian tiian 0 ott 15 22:54 sub2sup
prw-rw-r-- 1 tiian tiian 0 ott 15 22:54 sup2sub
	  

execute both the example programs to insert rows in tables and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ python example_xta_macbpa21.py 1 1 sup2sub sub2sup
Superior AP has sent XID '1279875137.60142b5fab4b4f2ea4524778a3f983d8.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received '1279875137.60142b5fab4b4f2ea4524778a3f983d8.e107cfeee0661d23c14e2bfc4bc9495b' reply from subordinate AP
MySQL, executing >INSERT INTO authors VALUES(1919, 'Levi', 'Primo')<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ python example_xta_macbpa22.py 1 1 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.60142b5fab4b4f2ea4524778a3f983d8.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.60142b5fab4b4f2ea4524778a3f983d8.e107cfeee0661d23c14e2bfc4bc9495b'
Subordinate AP has returned '1279875137.60142b5fab4b4f2ea4524778a3f983d8.e107cfeee0661d23c14e2bfc4bc9495b' to superior AP
PostgreSQL, executing >INSERT INTO authors VALUES(1921, 'Rigoni Stern', 'Mario')<
Subordinate AP has committed its branch
	  

Note

The first (superior) Application Program suspends and waits the return value from the second (subordinate) Application Program.

The XID generated by the subordinate AP differs from the XID generated by the superior AP in the last 16 hexadecimal symbols of the branch qualifier; the first 16 hexadecimal symbols are the same: this is not required by XA specification but can be useful for troubleshooting purposes.

Check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows from tables, but rollback:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ python example_xta_macbpa21.py 0 0 sup2sub sub2sup
Superior AP has sent XID '1279875137.ef2a359d5fd048de872d9300f2ce3db9.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received '1279875137.ef2a359d5fd048de872d9300f2ce3db9.e107cfeee0661d233fda43cfc67242ec' reply from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has rolled back its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ python example_xta_macbpa22.py 0 0 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.ef2a359d5fd048de872d9300f2ce3db9.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.ef2a359d5fd048de872d9300f2ce3db9.e107cfeee0661d233fda43cfc67242ec'
Subordinate AP has returned '1279875137.ef2a359d5fd048de872d9300f2ce3db9.e107cfeee0661d233fda43cfc67242ec' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has rolled back its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
+------+-----------+-------------+
| id   | last_name | first_name  |
+------+-----------+-------------+
| 1919 | Levi      | Primo       |
+------+-----------+-------------+
1 row in set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
 1921 | Rigoni Stern | Mario
(1 row)

testdb=>
	  

delete rows and commit:

[Shell terminal session - AP1]
tiian@ubuntu1404-64:~/tmp$ python example_xta_macbpa21.py 1 0 sup2sub sub2sup
Superior AP has sent XID '1279875137.8993e8485b5e4036ad5c536d1555f5a7.e107cfeee0661d23da9322f1ee73faba' to subordinate AP
Superior AP has received '1279875137.8993e8485b5e4036ad5c536d1555f5a7.e107cfeee0661d231e54035544b74771' reply from subordinate AP
MySQL, executing >DELETE FROM authors WHERE id=1919<
Superior AP has committed its branch
	  

[Shell terminal session - AP2]
tiian@ubuntu1404-64:~/tmp$ python example_xta_macbpa22.py 1 0 sup2sub sub2sup 
Subordinate AP has received XID '1279875137.8993e8485b5e4036ad5c536d1555f5a7.e107cfeee0661d23da9322f1ee73faba' from superior AP
Subordinate AP has created a branch with XID '1279875137.8993e8485b5e4036ad5c536d1555f5a7.e107cfeee0661d231e54035544b74771'
Subordinate AP has returned '1279875137.8993e8485b5e4036ad5c536d1555f5a7.e107cfeee0661d231e54035544b74771' to superior AP
PostgreSQL, executing >DELETE FROM authors WHERE id=1921<
Subordinate AP has committed its branch
	  

check MySQL table content:

[Shell terminal session - MySQL]
mysql> select * from authors;
Empty set (0.00 sec)

mysql>
	  

check PostgreSQL table content:

[Shell terminal session - PostgreSQL]
testdb=> select * from authors;
  id  |  last_name   | first_name 
------+--------------+------------
(0 rows)

testdb=>
	  

Source Code

Source code for programs example_xta_macbpa21.py and example_xta_macbpa22.py are installed in directory /opt/lixa/share/doc/lixa-X.Y.Z/examples/xta/python and are available on GitHub. Source code is fully commented for readability.



[52] You may notice that this pattern uses the same architecture shown in Figure 8.8, “Example of Multiple Applications, Consecutive Calls/Pseudo Synchronous with two Application Programs and two Resource Managers” because it differs from the other pattern only in the order of XTA calls.

[53] Oracle (R) Database, JDBC Developer's Guide, 12c Release 1 (12.1); there are analogous documents for different Oracle Database's versions