Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Last Resource Commit optimization

In theory, only databases supporting XA and providing a javax.sql.XADataSource implementation can be used with transaction managers. In practice, there is a way around this limitation.

Maximum one resource

Icon

There can be at most one datasource emulating XA with Last Resource Commit participating in a transaction. If it happens that you're trying to use a second emulating datasource while one has already been used, BTM will throw an exception.

The Last Resource Commit optimization (sometimes referred to as Last Resource Gambit or Last Agent optimization) allows a single non-XA database to participate in a XA transaction by cleverly ordering the resources.

Be Careful

Icon

There is one caveat with Last Resource Commit. There is a small chance that a transaction ends up with inconsistent results across participating resources if BTM crashes while a transaction is in-flight. The chances are small but they exist so be careful when using that feature. This is in no way a limitation of BTM but rather of the concept itself.

To enable it, you just have to create a PoolingDataSource using the bitronix.tm.resource.jdbc.lrc.LrcXADataSource as the XADataSource implementation.

Here's an example of code configuring a HSQLDB datasource:

and the same example viewed as a Resource Loader configuration

  • No labels