Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Bitronix Transaction Manager
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h1>Last Resource Commit optimization</h1> <table class="wysiwyg-macro" data-macro-name="note" data-macro-parameters="title=Be Careful" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vdGU6dGl0bGU9QmUgQ2FyZWZ1bH0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>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 chance is small but it exists so be careful when using that feature. This is in <em>no way</em> a limitation of BTM but of the concept itself.</p> <p>Please note that if you only intend to run transactions against a single database using Last Resource Commit this scenario is 100% safe, otherwise not.</p></td></tr></table> <p>In theory, only databases supporting XA and providing a <code>javax.sql.XADataSource</code> implementation can be used with transaction managers. In practice, there is a way around this limitation.</p> <p>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.</p> <table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="title=Maximum one non-XA resource" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86dGl0bGU9TWF4aW11bSBvbmUgbm9uLVhBIHJlc291cmNlfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>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. Again, this is not a limitation of BTM but of the concept itself.</p></td></tr></table> <p>To enable it, you just have to create a <code>PoolingDataSource</code> using the <a href="http://btm.codehaus.org/api/1.2/bitronix/tm/resource/jdbc/lrc/LrcXADataSource.html">bitronix.tm.resource.jdbc.lrc.LrcXADataSource</a> as the <code>XADataSource</code> implementation.</p> <p>Here's an example of code configuring a HSQLDB datasource:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> PoolingDataSource myDataSource = new PoolingDataSource(); myDataSource.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource"); myDataSource.setUniqueName("hsqldb"); myDataSource.setMaxPoolSize(5); myDataSource.setAllowLocalTransactions(true); myDataSource.getDriverProperties().setProperty("driverClassName", "org.hsqldb.jdbcDriver"); myDataSource.getDriverProperties().setProperty("url", "jdbc:hsqldb:/the/db/path"); myDataSource.getDriverProperties().setProperty("user", "sa"); myDataSource.getDriverProperties().setProperty("password", "theSaPassword"); </pre></td></tr></table> <p>and the same example viewed as a Resource Loader configuration</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> resource.ds.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource resource.ds.uniqueName=hsqldb resource.ds.maxPoolSize=5 resource.ds.allowLocalTransactions=true resource.ds.driverProperties.driverClassName=org.hsqldb.jdbcDriver resource.ds.driverProperties.url=jdbc:hsqldb:/the/db/path resource.ds.driverProperties.user=sa resource.ds.driverProperties.password=theSaPassword </pre></td></tr></table> <table class="wysiwyg-macro" data-macro-name="warning" data-macro-parameters="title=Mandatory pool settings" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3dhcm5pbmc6dGl0bGU9TWFuZGF0b3J5IHBvb2wgc2V0dGluZ3N9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"> <p>The LRC implementation relies on the <code>useTmJoin</code> and <code>deferConnectionRelease</code> pool properties which must always be <strong>true</strong> (the default value).<br /> Do not change these properties as this could force the transaction manager to reject the resource or worse, cause inconsistencies during commit phase.</p></td></tr></table> <p><img class="confluence-embedded-image confluence-external-resource" src="http://www.bitronix.be/images/shim.gif" data-image-src="http://www.bitronix.be/images/shim.gif"></p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced