Este conteúdo não está disponível no idioma selecionado.
6.4. XA Datasources
6.4.1. Create an XA Datasource with the Management Interfaces
Prerequisites:
This topic covers the steps required to create an XA datasource, using either the Management Console or the Management CLI.
Note
Procedure 6.9. Create an XA Datasource, Using Either the Management CLI or the Management Console
Management CLI
- Run the following Management CLI command to create an XA datasource, configuring the variables as appropriate:
Note
The value for DRIVER_NAME depends on the number of classes listed in the/META-INF/services/java.sql.Driver
file located in the JDBC driver JAR. If there is only one class, the value is the name of the JAR. If there are multiple classes, the value is the name of the JAR + driverClassName + "_" + majorVersion +"_" + minorVersion. Failure to do so will result in the following error being logged:JBAS014775: New missing/unsatisfied dependencies
For example, the DRIVER_NAME value required for the MySQL 5.1.31 driver, ismysql-connector-java-5.1.31-bin.jarcom.mysql.jdbc.Driver_5_1
.xa-data-source add --name=XA_DATASOURCE_NAME --jndi-name=JNDI_NAME --driver-name=DRIVER_NAME --xa-datasource-class=XA_DATASOURCE_CLASS
Configure the XA datasource properties
Set the server name
Run the following command to configure the server name for the host:/subsystem=datasources/xa-data-source=XA_DATASOURCE_NAME/xa-datasource-properties=ServerName:add(value=HOSTNAME)
Set the database name
Run the following command to configure the database name:/subsystem=datasources/xa-data-source=XA_DATASOURCE_NAME/xa-datasource-properties=DatabaseName:add(value=DATABASE_NAME)
- Enable the datasource:
xa-data-source enable --name=XA_DATASOURCE_NAME
Management Console
Navigate to the Datasources panel in the Management Console
- Select the Configuration tab from the top of the console.
- For Domain mode only, select a profile from the drop-down box at the top left.
- Expand themenu on the left of the console, then expand the menu.
- Select.
- Select the XA Datasource tab.
Create a new XA datasource
- Click.
- Enter the new XA datasource attributes in the Create XA Datasource wizard and click .
- Enter the JDBC driver details in the Create XA Datasource wizard and click .
- Enter the XA properties and click.
- Enter the connection settings in the Create XA Datasource wizard.
- Click thebutton to test the connection to the XA datasource and verify the settings are correct.
- Clickto finish
The XA datasource has been added to the server. It is now visible in either the standalone.xml
or domain.xml
file, as well as the management interfaces.
See Also:
6.4.2. Modify an XA Datasource with the Management Interfaces
This topic covers the steps required to modify an XA datasource, using either the Management Console or the Management CLI.
Prerequisites
Procedure 6.10. Modify an XA Datasource, Using Either the Management CLI or the Management Console
Management CLI
Configure XA datasource attributes
Use thewrite-attribute
command to configure a datasource attribute:/subsystem=datasources/xa-data-source=XA_DATASOURCE_NAME:write-attribute(name=ATTRIBUTE_NAME,value=ATTRIBUTE_VALUE)
Configure XA datasource properties
Run the following command to configure an XA datasource subresource:/subsystem=datasources/xa-data-source=DATASOURCE_NAME/xa-datasource-properties=PROPERTY_NAME:add(value=PROPERTY_VALUE)
- Reload the server to confirm the changes:
reload
Management Console
Navigate to the Datasources panel in the Management Console
- Select the Configuration tab from the top of the console.
- For Domain Mode only, select a profile from the drop-down box at top left.
- Expand themenu on the left of the console, then expand the menu.
- Select.
- Select the XA Datasource tab.
Edit the datasource
- Select the relevant XA datasource from the Available XA Datasources list. The XA datasource attributes are displayed in the Attributes panel below it.
- Select thebutton to edit the datasource attributes.
- Edit the XA datasource attributes and select thebutton when done.
The XA datasource has been configured. The changes are now visible in either the standalone.xml
or domain.xml
file, as well as the management interfaces.
- To create a new datasource, refer here: Section 6.4.1, “Create an XA Datasource with the Management Interfaces”.
- To remove the datasource, refer here: Section 6.4.3, “Remove an XA Datasource with the Management Interfaces”.
6.4.3. Remove an XA Datasource with the Management Interfaces
This topic covers the steps required to remove an XA datasource from JBoss EAP 6, using either the Management Console or the Management CLI.
Prerequisites
Procedure 6.11. Remove an XA Datasource Using Either the Management CLI or the Management Console
Management CLI
- Run the following command to remove an XA datasource:
xa-data-source remove --name=XA_DATASOURCE_NAME
Management Console
Navigate to the Datasources panel in the Management Console
- Select the Configuration tab from the top of the console.
- For Domain mode only, select a profile from the drop-down box in the top left.
- Expand themenu on the left of the console, then expand the menu.
- Select.
- Select the XA Datasource tab.
- Select the registered XA datasource to be deleted, and clickto permanently delete the XA datasource.
The XA datasource has been removed from the server.
- To add a new XA datasource, refer here: Section 6.4.1, “Create an XA Datasource with the Management Interfaces”.
6.4.4. XA Recovery
6.4.4.1. About XA Recovery Modules
com.arjuna.ats.jta.recovery.XAResourceRecovery
.
6.4.4.2. Configure XA Recovery Modules
Attribute | Description |
---|---|
recovery-username |
The username the recovery module should use to connect to the resource for recovery.
|
recovery-password |
The password the recovery module should use to connect to the resource for recovery.
|
recovery-security-domain |
The security domain the recovery module should use to connect to the resource for recovery.
|
recovery-plugin-class-name |
If you need to use a custom recovery module, set this attribute to the fully-qualified class name of the module. The module should extend class
com.arjuna.ats.jta.recovery.XAResourceRecovery .
|
recovery-plugin-properties |
If you use a custom recovery module which requires properties to be set, set this attribute to the list of comma-separated key=value pairs for the properties.
|
Note
Vendor-Specific Configuration Information
- Oracle
- If the Oracle datasource is configured incorrectly, you may see errors like the following in your log output:
Example 6.11. Incorrect configuration error
WARN [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.recovery.xarecovery1] Local XARecoveryModule.xaRecovery got XA exception javax.transaction.xa.XAException, XAException.XAER_RMERR
To resolve this error, ensure that the Oracle user configured inrecovery-username
has access to the tables needed for recovery. The following SQL statement shows the correct grants for Oracle 11g or Oracle 10g R2 instances patched for Oracle bug 5945463.Example 6.12. Grant configuration
GRANT SELECT ON sys.dba_pending_transactions TO recovery-username; GRANT SELECT ON sys.pending_trans$ TO recovery-username; GRANT SELECT ON sys.dba_2pc_pending TO recovery-username; GRANT EXECUTE ON sys.dbms_xa TO recovery-username;
If you use an Oracle 11 version prior to 11g, change the finalEXECUTE
statement to the following:GRANT EXECUTE ON sys.dbms_system TO recovery-username;
- PostgreSQL and Postgres Plus Advanced Server
- For PostgreSQL to be able to handle XA transaction, change the configuration parameter
max_prepared_transactions
to an value higher than 0. - MySQL
- No special configuration is required. For more information, refer to MySQL documentation.
- IBM DB2
- No special configuration is required. For more information, refer to IBM DB2 documentation.
- Sybase
- Sybase expects XA transactions to be enabled on the database. Without correct database configuration, XA transactions will not work.
enable xact coordination
enables or disables Adaptive Server transaction coordination services. When this parameter is enabled, Adaptive Server ensures that updates to remote Adaptive Server data commit or roll back with the original transaction. To enable transaction coordination, use:sp_configure 'enable xact coordination', 1
. - MSSQL
- For more information, refer to Microsoft documentation. You can also refer http://msdn.microsoft.com/en-us/library/aa342335.aspx as a starting point.
Vendor-specific issues and their consequences
- Oracle
- There are no known issues related to database.
- PostgreSQL
- Jdbc driver returns XAER_RMERR when an error occurs during the call of commit method protocol. Database returns this error code and leaves the transaction in
in-doubt
state on the database side. The correct return code should be XAER_RMFAIL or XAER_RETRY. For more information, see https://github.com/pgjdbc/pgjdbc/issues/236. This causes the transaction to be left in theHeuristic
state on the EAP side and holding locks in database which requires user intervention. - The incorrect error code returned by the jdbc driver can cause data inconsistency in some cases. For more information, refer to https://developer.jboss.org/thread/251537, https://github.com/pgjdbc/pgjdbc/issues/236
- Postgres Plus Advanced Server
- Jdbc driver returns XAER_RMERR when an error occurs during the call of commit method protocol. Database returns this error code and leaves the transaction in
in-doubt
state on the database side. The correct return code should be XAER_RMFAIL or XAER_RETRY. For more information, see https://github.com/pgjdbc/pgjdbc/issues/236. This causes the transaction to be left in theHeuristic
state on the EAP side and holding locks in database which requires user intervention. - The incorrect error code returned by the jdbc driver can cause data inconsistency in some cases. For more information, refer to https://developer.jboss.org/thread/251537
- If
XAResource.rollback
is called for the same XID more than once thenXAException
is thrown. Calling rollback against the same XID several times is compliant with JTS spec and noXAException
should be thrown. For more information, see https://github.com/pgjdbc/pgjdbc/issues/78.
- MySQL
- MySQL is not capable of handling XA transactions. If a client is disconnected the MySQL then all the information about such transactions is lost. For more information, see http://bugs.mysql.com/bug.php?id=12161.
- IBM DB2
- There are no known issues related to database.
- Sybase
- Jdbc driver returns XAER_RMERR when an error occurs during the call of commit method protocol. Database returns this error code and leaves the transaction in
in-doubt
state on the database side. The correct return code should be XAER_RMFAIL or XAER_RETRY. For more information, see https://github.com/pgjdbc/pgjdbc/issues/236. This causes the transaction to be left in theHeuristic
state on the EAP side and holding locks in database which requires user intervention. - If
XAResource.rollback
is called for the same XID more than once thenXAException
is thrown. Calling rollback against the same XID several times is compliant with JTS spec and noXAException
should be thrown. For more information, see https://github.com/pgjdbc/pgjdbc/issues/78.
- MSSQL
- Jdbc driver returns XAER_RMERR when an error occurs during the call of commit method protocol. Database returns this error code and leaves the transaction in
in-doubt
state on the database side. The correct return code should be XAER_RMFAIL or XAER_RETRY. For more information, see https://github.com/pgjdbc/pgjdbc/issues/236. This causes the transaction to be left in theHeuristic
state on the EAP side and holding locks in database which requires user intervention.This issue was reported on the Microsoft Connect site at https://connect.microsoft.com/SQLServer/feedback/details/1207381/jdbc-driver-is-not-xa-compliant-in-case-of-connection-failure-error-code-xaer-rmerr-is-returned-instead-of-xaer-rmretry. - If
XAResource.rollback
is called for the same XID more than once thenXAException
is thrown. Calling rollback against the same XID several times is compliant with JTS spec and noXAException
should be thrown. For more information, see https://github.com/pgjdbc/pgjdbc/issues/78. - The call of
XAResource.rollback
for the same XID causes the following message being logged in server log file.WARN [com.arjuna.ats.jtax] ...: XAResourceRecord.rollback caused an error from resource ... in transaction ...: java.lang.NullPointerException
- Messaging
IBM Websphere
- When JTS is used then second call of rollback against the same XID during the periodic recovery can cause an error to be logged in the log file. Second rollback against the same XID is JTS complaint and can be ignored.When RAR does not know such XID, then XAER_NOTA return code is expected. But IBM Websphere may return an incorrect return code XAER_RMFAIL.
The method 'xa_rollback' has failed with errorCode '-7' due to the resource being closed.'
ActiveMQ
- Resource adapter returns XAER_RMERR when an error occurs during the call of commit method protocol, for example network disconnection. Resource adapter returns this error code back to transaction manager and it causes the transaction being left in
in-doubt
state on message broker side. This behaviour is against XA specification and the correct return code should be XAER_RMFAIL or XAER_RETRY. The wrong error code can cause data inconsistency in some cases. For more information, refer to https://developer.jboss.org/thread/251537 .WARN [com.arjuna.ats.jtax] ...: XAResourceRecord.rollback caused an XA error: ARJUNA016099: Unknown error code:0 from resource ... in transaction ...: javax.transaction.xa.XAException: Transaction ... has not been started.
TIBCO
- When JTS is used then second call of rollback against the same XID during the periodic recovery can cause an error to be logged in the log file. Second rollback against the same XID is JTS complaint and can be ignored.
WARN [com.arjuna.ats.jtax] ...: XAResourceRecord.rollback caused an XA error: XAException.XAER_RMFAIL from resource ... in transaction ...: javax.transaction.xa.XAException