Skip to content

Overview

Concepts and Principles

Development

Overview

IDEs

API Explorer

Releases

Release Notes

TORO Integrate

Coder Studio

Coder Cloud

Bug Reports

Search

Database XA Transactions

Introduction

According to Oracle:

XA is a two-phase commit protocol that is natively supported by many databases and transaction monitors. It ensures data integrity by coordinating single transactions accessing multiple relational databases. XA guarantees that transactional updates are committed in all of the participating databases, or are fully rolled back out of all of the databases, reverting to the state prior to the start of the transaction.1

XA transactions are supported by TORO Integrate and the databaseTransaction.DatabaseMigration.gloop service of the examples package demonstrates how XA transactions can be used in Gloop. In this example, there are two data sources and the goal of the service is to migrate the data from the first data source onto the second.

Requirement

When performing XA transactions, ensure that the participating database connection pools have their xa properties set to true.

Related articles

Please see the following articles for more information:

Try It!

Under the Coder Navigator, expand the examples package entry and navigate to the code folder. Afterwards, look for the databaseTransaction package. This package contains the files and/or directories shown below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
examples
├── ...
└── code
    └── databaseTransaction
        ├── DatabaseMigration.gloop
        └── util
            ├── DatabaseXAHelper.gloop
            ├── DisableDatabaseXA.gloop
            ├── EnableDatabaseXA.gloop
            └── PopulateDatasource.gloop

Inspect and run the DatabaseMigration.gloop service to see XA database transactions in action. This Gloop service has its steps decorated with comments to help explain the goal or purpose of each of its components.

Output of DatabaseMigration.gloop

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
24/04/18 14:01:16.553 INFO  [Integrate] Enabling xa for data sources [demo_sql_db, demo_sql_newdb]
24/04/18 14:01:17.067 INFO  [Integrate] -- inserted row selectMultipleNamesOutputCursor{
ID = 8
FIRST_NAME = Jack
LAST_NAME = Baker
} to demo_sql_newdb
24/04/18 14:01:17.223 INFO  [Integrate] -- deleted row selectMultipleNamesOutputCursor{
ID = 8
FIRST_NAME = Jack
LAST_NAME = Baker
} to demo_sql_db

...

24/04/18 14:01:17.265 INFO  [Integrate] -- inserted row selectMultipleNamesOutputCursor{
ID = 12
FIRST_NAME = Juan
LAST_NAME = Dela Cruz
} to demo_sql_newdb
24/04/18 14:01:17.275 INFO  [Integrate] -- deleted row selectMultipleNamesOutputCursor{
ID = 12
FIRST_NAME = Juan
LAST_NAME = Dela Cruz
} to demo_sql_db
24/04/18 14:01:17.410 INFO  [Integrate] -- Populate demo_sql_db with demo_sql_newdb data(s)
24/04/18 14:01:17.599 INFO  [Integrate] Disabling xa for data sources [demo_sql_db, demo_sql_newdb]

How It Works...

Simply put, all this service does is migrate data from dataSource1 to dataSource2 and delete the copied row(s) from dataSource1 if successful.


  1. Oracle Corporation. (n.d.). XA Transactions. Retrieved October 23, 2018, from https://docs.oracle.com/cd/E19509-01/820-5892/ref_xatrans/index.html