Product SiteDocumentation Site

2.5. Recovering XAConnections

When recovering from failures, JBossTS requires the ability to reconnect to databases that were in use prior to the failures in order to resolve any outstanding transactions. Most connection information will be saved by the transaction service during its normal execution, and can be used during recovery to recreate the connection. However, it is possible that not all such information will have been saved prior to a failure (for example, a failure occurs before such information can be saved, but after the database connection is used). In order to recreate those connections it is necessary to provide implementations of the following JBossTS interface com.arjuna.ats.jta.recovery.XAResourceRecovery, one for each database that may be used by an application.

Note

if using the transactional JDBC driver provided with JBossTS, then no additional work is necessary in order to ensure that recovery occurs.
To inform the recovery system about each of the XAResourceRecovery instances, it is necessary to specify their class names through the JTAEnvironmentBean.xaResourceRecoveryInstances property variable, whose values is a list of space separated strings, each being a classname followed by optional configuration information.
JTAEnvironmentBean.xaResourceRecoveryInstances=com.foo.barRecovery
Additional information that will be passed to the instance when it is created may be specified after a semicolon:
JTAEnvironmentBean.xaResourceRecoveryInstances=com.foo.barRecovery;myData=hello

Note

These properties need to go into the JTA section of the property file.
Any errors will be reported during recovery.
Example 2.3. XAResourceRecovery interface
public interface XAResourceRecovery {
	public XAResource getXAResource() throws SQLException;

	public boolean initialise(String p);

	public boolean hasMoreResources();
};

Each method should return the following information:

Note

If you want your XAResourceRecovery instance to be called during each sweep of the recovery manager then you should ensure that once hasMoreResources returns false to indicate the end of work for the current scan it then returns true for the next recovery scan.