Chapter 2. Configuring the Connection Factory
Abstract
The JMS binding component needs to have access to your JMS provider's connection factory. This is configured in the XML file and the specifics depend on the JMS provider in use.
Important
The Java Business Integration components of Red Hat JBoss Fuse are considered deprecated. You should consider migrating any JBI applications to OSGi.
When working with a JMS broker, a client application needs a
ConnectionFactory
object to create connections to the broker. The ConnectionFactory
object is a JMS object that is provided along with the JMS broker. Each JMS provider has a unique ConnectionFactory
object that uses properties specific to a particular JMS implementation.
When using the Red Hat JBoss Fuse JMS binding component, you must configure each service unit with the information it needs to load a
ConnectionFactory
object. Often the ConnectionFactory
object is looked up through JNDI. However, the information needed depends on the JMS provider you are using.
Commonly used JMS providers include Red Hat JBoss A-MQ, Apache ActiveMQ, IBM's WebShere® MQ, BEA's WebLogic®, and Progress Software's SonicMQ®. JBoss A-MQ and Apache ActiveMQ can be configured using simple Spring XML. Other JMS providers must be configured using either JNDI or using custom Spring beans. This chapter provides basic information for configuring the
ConnectionFactory
objects for each of these platforms.
2.1. Using Apache ActiveMQ Connection Factories
Overview
The recommended method for creating connections to Apache ActiveMQ, is by using the Jencks AMQPool. It provides support for using a scalable pool of connections for managing overhead. You can download the needed jar from http://repo1.maven.org/maven2/org/jencks/jencks-amqpool/2.0/jencks-amqpool-2.0.jar. Once the jar is downloaded, you need to add it to your classpath. The easiest way to do this is to place the jar into your
InstallDir\lib
folder.
Note
The examples included with Red Hat JBoss Fuse use the standard Apache ActiveMQ connection factory. This is fine for testing purposes, but is not robust enough for enterprise deployments.
The Jencks AMQPool supplies three connection factories:
Namespace
To add the AMQPool configuration elements to your endpoint's configuration, you need to add the following XML namespace declaration to your
beans
element:
xmlns:amqpool="http://jencks.org/amqpool/2.0"
Simple pool
The simple pooling connection factory supports pooling, but does not support transactions. It is specified using the
amqpool:pool
element. The attributes used to configure the simple pooled connection factory are described in Table 2.1, “Attributes for Configuring the Simple AMQPool Connection Factory”.
Example 2.1, “Configuring a Simple AMQPool Connection Factory” shows a configuration snippet for configuring the simple AMQPool connection factory.
Example 2.1. Configuring a Simple AMQPool Connection Factory
<beans xmlns:amqpool="http://jencks.org/amqpool/2.0" ... > ... <amqpool:pool id="connectionFactory" url="tcp://localhost:61616" maxConnections="8" /> </beans>
XA pool
The XA pooling connection factory supports XA transactions and late enlistment. It is specified using the
amqpool:xa-pool
element. The attributes used to configure the XA pooled connection factory are described in Table 2.2, “Attributes for Configuring the XA AMQPool Connection Factory”.
Example 2.2, “Configuring an XA AMQPool Connection Factory” shows a configuration snippet for configuring an XA AMQPool connection factory.
Example 2.2. Configuring an XA AMQPool Connection Factory
<beans xmlns:amqpool="http://jencks.org/amqpool/2.0" xmlns:jencks="http://jencks.org/2.0" ... > ... <amqpool:xa-pool id="connectionFactory" url="tcp://localhost:61616" maxConnections="8" transactionManager="#transactionManager" /> <jencks:transactionManager id="transactionManager" transactionLogDir="./data/txlog" defaultTransactionTimeoutSeconds="600" /> </beans>
JCA pool
The JCA pooling connection factory is intended to be used inside of J2EE environments or in conjunction with the Jencks JCA environment. It is specified using the
amqpool:jca-pool
element. The attributes used to configure the JCA pooled connection factory are described in Table 2.3, “Attributes for Configuring the JCA AMQPool Connection Factory”.
Example 2.3, “Configuring a JCA AMQPool Connection Factory” shows a configuration snippet for configuring the JCA AMQPool connection factory.
Example 2.3. Configuring a JCA AMQPool Connection Factory
<beans xmlns:amqpool="http://jencks.org/amqpool/2.0" xmlns:jencks="http://jencks.org/2.0" ... > ... <amqpool:jca-pool id="connectionFactory" url="tcp://localhost:61616" maxConnections="8" transactionManager="#transactionManager" name="joeFred" /> <jencks:transactionManager id="transactionManager" transactionLogDir="./data/txlog" defaultTransactionTimeoutSeconds="600" /> </beans>