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>XA Connection factories only available from JNDI</h1> <p>The JMS specification does not specify that <code>XAConnectionFactory</code> implementations should be javabeans. Because of this, it is not always possible to build a <code>PoolingConnectionFactory</code> directly.</p> <h4>Contents</h4> <img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e3RvYzptYXhMZXZlbD0zfG1pbkxldmVsPTJ9&locale=en_GB&version=2" data-macro-name="toc" data-macro-parameters="maxLevel=3|minLevel=2"> <h2>The JndiXAConnectionFactory</h2> <p>When you have no way to create a <code>XAConnectionFactory</code> in a javabean way, you can specify the <code>className</code> argument of <code>PoolingConnectionFactory</code> to be <a href="http://btm.codehaus.org/api/2.0.1/bitronix/tm/resource/jms/JndiXAConnectionFactory.html">bitronix.tm.resource.jms.JndiXAConnectionFactory</a>. This class is an implementation of <code>XAConnectionFactory</code> that will wrap another implementation fetched from JNDI.</p> <p>Set the <code>name</code>, <code>initialContextFactory</code> and <code>providerUrl</code> properties respectively to the JNDI name of the <code>XAConnectionFactory</code> implementation, the initial context factory and provider URL used to access the JNDI server. The last two parameters can be omitted if the <code>XAConnectionFactory</code> implementation is available in the default JNDI context (inside an application server for instance).</p> <p>Here is what your code would look like for creating a SwiftMQ <code>PoolingConnectionFactory</code>:</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.JndiXAConnectionFactory"); myConnectionFactory.setUniqueName("swiftmq"); myConnectionFactory.setMaxPoolSize(5); myConnectionFactory.getDriverProperties().setProperty("name", "QueueConnectionFactory@router1"); myConnectionFactory.getDriverProperties().setProperty("initialContextFactory", "com.swiftmq.jndi.InitialContextFactoryImpl"); myConnectionFactory.getDriverProperties().setProperty("providerUrl", "smqp://localhost:4001/timeout=10000"); Connection c = myConnectionFactory.createConnection(); // create some session then send or receive some message c.close(); myConnectionFactory.close(); </pre></td></tr></table> <h2>JNDI credentials</h2> <p>It is often required to use credentials to be able to connect to a JNDI repository. The <a href="http://btm.codehaus.org/api/2.0.1/bitronix/tm/resource/jms/JndiXAConnectionFactory.html">bitronix.tm.resource.jms.JndiXAConnectionFactory</a> class fully supports this via its <code>securityPrincipal</code> and <code>securityCredentials</code> properties as illustrated bellow:</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.getDriverProperties().setProperty("name", "QueueConnectionFactory@router1"); myConnectionFactory.getDriverProperties().setProperty("initialContextFactory", "com.swiftmq.jndi.InitialContextFactoryImpl"); myConnectionFactory.getDriverProperties().setProperty("providerUrl", "smqp://localhost:4001/timeout=10000"); // set JNDI username / password myConnectionFactory.getDriverProperties().setProperty("securityPrincipal", "jndiUser"); myConnectionFactory.getDriverProperties().setProperty("securityCredentials", "jndiPassword"); ... </pre></td></tr></table> <h2>Other JNDI properties</h2> <p>There are some other properties to make the <code>JndiXAConnectionFactory</code> more flexible:</p> <ul> <li><strong>urlPkgPrefixes</strong> Use it to set the <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/naming/Context.html#URL_PKG_PREFIXES">Context#URL_PKG_PREFIXES</a>.</li> <li><strong>narrowJndiObject</strong> Use it to indicate if <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/rmi/PortableRemoteObject.html#narrow%28java.lang.Object,%20java.lang.Class%29">PortableRemoteObject.narow()</a> should be applied on the object fetched from JNDI.</li> <li><strong>extraJndiProperties</strong> Extra JNDI environment properties added the the <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/naming/InitialContext.html">InitialContext</a>.</li> </ul> <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