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.
Contents
| Table of Contents | ||||
|---|---|---|---|---|
|
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 bitronix.tm.resource.jms.JndiXAConnectionFactory. This class is an implementation of XAConnectionFactory that will wrap another implementation fetched from JNDI.
...
| Code Block |
|---|
PoolingConnectionFactory myConnectionFactory = new PoolingConnectionFactory ();
myConnectionFactory.setClassName("bitronix.tm.resource.jms.JndiXAConnectionFactory");
myConnectionFactory.setUniqueName("swiftmq");
myConnectionFactory.setMaxPoolSize(5);
myConnectionFactory.setAllowLocalTransactions(true);
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();
|
JNDI credentials
It is often required to use credentials to be able to connect to a JNDI repository. The bitronix.tm.resource.jms.JndiXAConnectionFactory class fully supports this via its securityPrincipal and securityCredentials properties as illustrated bellow:
...