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
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 for JMS</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 JMS server using Last Resource Commit this scenario is 100% safe, otherwise not.</p></td></tr></table> <p>In theory, only JMS servers supporting XA and providing a <code>javax.jms.XAConnectionFactory</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 resource (JMS server or 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 resource emulating XA with Last Resource Commit participating in a transaction. If it happens that you're trying to use a second emulating resource 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>PoolingConnectionFactory</code> using the <a href="http://btm.codehaus.org/api/2.0.1/bitronix/tm/resource/jms/lrc/LrcXAConnectionFactory.html">bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory</a> as the <code>XAConnectionFactory</code> implementation.</p> <p>Here's an example of code configuring a ActiveMQ 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> PoolingConnectionFactory myConnectionFactory = new PoolingConnectionFactory(); myConnectionFactory.setClassName("bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory"); myConnectionFactory.setUniqueName("amq-lrc"); myConnectionFactory.setMaxPoolSize(5); myConnectionFactory.getDriverProperties().setProperty("connectionFactoryClassName", "org.apache.activemq.ActiveMQConnectionFactory"); myConnectionFactory.getDriverProperties().setProperty("properties.brokerUrl", "tcp://localhost:61616"); </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.jms.lrc.LrcXAConnectionFactory resource.ds.uniqueName=amq-lrc resource.ds.maxPoolSize=5 resource.ds.driverProperties.connectionFactoryClassName=org.apache.activemq.ActiveMQConnectionFactory resource.ds.driverProperties.properties.brokerUrl=tcp://localhost:61616 </pre></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