This page doesn't show a lot of informations and it is preferable to go to look at directly in the cvs ;-). The cvs is hosted by codehaus (cvs.tranql.codehaus.org) and the cvs root is /home/projects/tranql/scm.
The project only wrap JDBC driver and doesn't add support to convert a no-xa driver into an xa driver... An interested approach is to develop an integration between Tranql and XAPool. So you can easily create an XA DataSource from a simple DataSource and manage its connections with a JCA connection manager.
For example, with Tranql, you can configure a pool of connections with JCA in this way (using the Spring JCA support of Spring):
<bean id="tranqlManagedConnectionFactory"
class="org.tranql.connector.jdbc.XADriverMCF">
<property name="driverName">
<value>org.hsqldb.jdbcDriver</value>
</property>
<property name="url">
<value>jdbc:hsqldb:hsql://localhost:9002</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
So, to transform this DataSource in a XA compliant one, you only need to change the implementation of the ManagedConnectionManager. This XAPoolDataSourceMCF one integrates XAPool and use its StandardXADataSource class.
The configuration is now:
<bean id="tranqlManagedConnectionFactory"
class="org.tranql.connector.jdbc.XAPoolDataSourceMCF ">
<property name="driverName">
<value>org.hsqldb.jdbcDriver</value>
</property>
<property name="url">
<value>jdbc:hsqldb:hsql://localhost:9002</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
Note: A big problem is that XAPool internally manages the enlistment/delistment of XAResource. So you need to patch this tool to remove the call of enlist and delist on the current transaction.
Here is a sample implementation of XAPoolDataSourceMCF:
package org.tranql.connector.jdbc;
import java.sql.SQLException;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import org.enhydra.jdbc.standard.StandardXADataSource;
import org.tranql.connector.AllExceptionsAreFatalSorter;
public class XAPoolDataSourceMCF extends AbstractXADataSourceMCF {
public XAPoolDataSourceMCF() {
super(new StandardXADataSource(),new AllExceptionsAreFatalSorter());
}
public String getUserName() {
return ((StandardXADataSource)xaDataSource).getUser();
}
public String getPassword() {
return ((StandardXADataSource)xaDataSource).getPassword();
}
public void setDriverName(String driverName) {
try {
((StandardXADataSource)xaDataSource).setDriverName(driverName);
} catch (SQLException ex) { ex.printStackTrace(); }
}
public void setUrl(String url) {
((StandardXADataSource)xaDataSource).setUrl(url);
}
public void setUser(String user) {
((StandardXADataSource)xaDataSource).setUser(user);
}
public void setPassword(String password) {
((StandardXADataSource)xaDataSource).setPassword(password);
}
}
The latest ManagedConnectionFactory implementation supports XA transactions!
No comments:
Post a Comment