AMQPool
Jencks contains an JMS pooled ConnectionFactory specific for ActiveMQ. The main difference with the ActiveMQ provided one is that it plays nicely in a transacted environment (XA or JCA) and can also have better performances in some cases (see this blog).
This connection pool comes with three spring factories:
- PooledConnectionFactory: this is the most simple one that can be used in non transacted environments
- XaPooledConnectionFactory: this factory supports XA transaction late enlistement
- JcaPooledConnectionFactory: this one can be used inside jencks JCA environment
Note that you always use a JcaPooledConnectionFactory if you prefer.
Parameters
| Property | Type | Description |
|---|---|---|
| connectionFactory | org.apache.activemq.ActiveMQConnectionFactory | The underlying ActiveMQ connection factory to use. You can provide it directly or let the factory create it for you using the brokerUrl property |
| brokerUrl | String | The URL of the ActiveMQ broker (tcp://localhost:61616 for example |
| maxConnections | int | The number of connections to the broker to use simultaneously. The default value is 1, but you can safely increase it to 8 or so in all conditions. |
| maximumActive | int | The maximum number of active sessions for a given connection (defaults to 500) |
| poolFactory | org.apache.commons.pool.ObjectPoolFactory | the pool factory if you want a specific behavior (a default one will be created that is usually fine) |
| transactionManager | javax.transaction.TransactionManager | For XA and JCA pools, the transaction manager should be set |
| name | String | For JCA pools, a name must be set to a unique string identifying the activemq broker |
Spring configuration
<beans> <bean id="connectionFactory" class="org.jencks.amqpool.PooledConnectionFactory"> <constructor-arg value="tcp://localhost:61616" /> <property name="maxConnections" value="8" /> </bean> </beans>
<beans> <bean id="connectionFactory" class="org.jencks.amqpool.XaPooledConnectionFactory"> <constructor-arg value="tcp://localhost:61616" /> <property name="maxConnections" value="8" /> <property name="transactionManager" ref="transactionManager" /> </bean> </beans>
<beans> <bean id="connectionFactory" class="org.jencks.amqpool.JcaPooledConnectionFactory"> <constructor-arg value="tcp://localhost:61616" /> <property name="maxConnections" value="8" /> <property name="transactionManager" ref="transactionManager" /> <property name="name" value="LocalBroker" /> </bean> </beans>
XBean configuration
If you're using XBean, you can use the following syntax:
<beans xmlns:amqpool="http://jencks.org/amqpool/2.0"> <amqpool:pool id="connectionFactory" url="tcp://localhost:61616" maxConnections="8" /> </beans>
<beans xmlns:amqpool="http://jencks.org/amqpool/2.0"> <amqpool:xa-pool id="connectionFactory" url="tcp://localhost:61616" maxConnections="8" transactionManager="#transactionManager" /> </beans>
<beans xmlns:amqpool="http://jencks.org/amqpool/2.0"> <amqpool:jca-pool id="connectionFactory" url="tcp://localhost:61616" maxConnections="8" transactionManager="#transactionManager" name="LocalBroker" /> </beans>
