Skip to end of metadata
Go to start of metadata

XA Connection factories only available from JNDI

The JMS specification does not specify that XAConnectionFactory implementations should be javabeans. Because of this, it is not always possible to build a PoolingConnectionFactory directly.


The JndiXAConnectionFactory

When you have no way to create a XAConnectionFactory in a javabean way, you can specify the className argument of PoolingConnectionFactory to be This class is an implementation of XAConnectionFactory that will wrap another implementation fetched from JNDI.

Set the name, initialContextFactory and providerUrl properties respectively to the JNDI name of the XAConnectionFactory implementation, the initial context factory and provider URL used to access the JNDI server. The last two parameters can be omitted if the XAConnectionFactory implementation is available in the default JNDI context (inside an application server for instance).

Here is what your code would look like for creating a SwiftMQ PoolingConnectionFactory:

JNDI credentials

It is often required to use credentials to be able to connect to a JNDI repository. The class fully supports this via its securityPrincipal and securityCredentials properties as illustrated bellow:

Other JNDI properties

There are some other properties to make the JndiXAConnectionFactory more flexible:

  • No labels

1 Comment

  1. I had problems when sending to HornetQ running inside JBoss 7.1.

    The connection factory which the JBoss JNDI gives back isn't quite an XAConnectionFactory, even though it seems capable as it has all the relevant methods.

    See for more details on what I did, but basically, I created a wrapper factory, similar to