JMS pools configuration
BTM XA connection factories can be created - like their JDBC conterpart - via some java code or via a BTM-specific tool called the Resource Loader. You are free to choose the method you prefer, there is absolutely no difference between them.
|Supported JMS version|
BTM only supports the JMS 1.1 API. Only servers supporting it can be used with BTM. There is currently no way to make BTM work with JMS 1.0.2 API.
BTM comes bundled with a JMS XA connection pool. It is very easy to configure it. You basically have to create an instance of bitronix.tm.resource.jms.PoolingConnectionFactory set some properties and you're done.
Here is an example of datasource creation that connects to an ActiveMQ JMS server:
1. The Bitronix
PoolingConnectionFactory is a javabean that implements
2. You have to specify the JMS server's
XAConnectionFactory implementation here.
3. Each connection factory must be assigned a unique name. This is required for distributed crash recovery.
4. This connection factory will pool 5 connections.
5. You have to set
allowLocalTransactions to true if you want to be able to send or receive messages outside of XA transactions scope.
6. The driverProperties is a
java.util.Properties object. You have to add into it a set of property name / property value of the
ActiveMQXAConnectionFactory class. You have to refer to the JMS server's documentation to know what can / has to be set. The ActiveMQXAConnectionFactory javadoc contains this list for the ActiveMQ case. BTM will perform conversion from
boolean or to
int when necessary.
7,8. You can now use the
PoolingConnectionFactory like any other
9. Remember to close the
PoolingConnectionFactory after you're done with it to release the connections.
Like for JDBC, the connection pool will be initialized during the first call to
createConnection(). It might be desirable to initialize the pool eagerly, like during application startup rather than having to wait for the first requests. This can also be done by calling
Now line 7 will initialize the pool and create the 5 connections to the database instead of line 8.