Wednesday, July 25, 2007

What is an XA driver?

XA is a set of distributed transaction protocols defined by Open Group.
XA provide interfaces that could be used for cross platform transactions. Currently, much of the famous databases provided XA-compliant drivers. XA-compliant driver means that the transaction manager could send XA command directly to the driver.
Oops, sorry, in the world of distributed transaction, there are transaction manager and resource managers. Transaction manager coordinate the transaction, orchestrating the two-phase commit for each of the resource manager.
In JEE point of view, and transaction manager could be a type 3 JDBC driver, and the resource managers could be an XA compliant JDBC drivers, or general type 4 JDBC driver in which the type 3 JDBC driver will emulate XA command using common JDBC transaction commands.
In WebLogic console, when we setup a connection pool, usually we will be asked whether we want to assign an XA driver or just ordinary driver. XA drivers will have a significant overhead imposed into it, so make sure you only use the XA drivers when really required. It is common to have an XA-compliant version of connection pool and non-XA-compliant connection pool, both connecting to the same database, to avoid performance penalty when we don't need two-phase commit.
In my former company, we have a clustered WebLogic server installation with each of the databases have two pairs of connection pools, a non-XA and XA-compliant driver. Due to clustered environment, database connection are using RMI through JNDI lookup. For read only data, always use non-XA connection pool to increase performance.

1 comment:

  1. Hi Opa Daniel, how are you ? nice blog :)

    Just want to add below, CMIIW :
    As short as I know, there are 3 kinds of driver, the first one is No Transaction driver. This is the one that U suggested to be used for read only data. The second is Local Transaction. This is to be used when we need to do multiple atomic transactions within a single datasource. Let's say I have to update lots of tables in a database all at once, with all commit or nothing. And the last one is XA Transaction. This is to be used when we need to du multipe atomic transaction, on multiple resources like JDBC and JMS, or JDBC and JDBC, etc.

    ReplyDelete