此内容没有您所选择的语言版本。

1.2. Install the ActiveMQ Resource Adapter


Overview

This section describes how to find, install, and configure the ActiveMQ resource adapter into a standalone instance of the JBoss Enterprise Application Platform.
A resource adapter is a kind of plug-in for a J2EE container. The J2EE standard defines the resource adapter framework, which makes it possible to expand the core J2EE container, adding new features and functionality. By installing the ActiveMQ resource adapter, you make it possible for message driven beans and servlets to communicate through an external JBoss A-MQ broker instance. The JBoss A-MQ broker can thus be used as the underlying messaging system in the container.

Resource adapter location

You can find the ActiveMQ resource adapter archive file, activemq-rar-5.9.0.redhat-610379.rar, at either of the following locations:
  • In the following Zip archive file:
    InstallDir/extras/apache-activemq-5.9.0.redhat-610379-bin.zip
    Copy to Clipboard Toggle word wrap
    After expanding the archive, the resource adapter file can be found in the following sub-directory:
    apache-activemq-5.9.0.redhat-610379/lib/optional
    Copy to Clipboard Toggle word wrap
  • Directly from the Red Hat JBoss Fuse Maven repository, at the following URL:
    http://repo.fusesource.com/nexus/content/groups/public/org/apache/activemq/activemq-rar/
    Copy to Clipboard Toggle word wrap
    Download the .rar archive file from the appropriately versioned sub-directory, 5.9.0.redhat-610379.

Configuration files

The following configuration files are needed for the the ActiveMQ resource adapter (when installed in a standalone instance of the JBoss Enterprise Application Platform):
InstallDir/standalone/configuration/standalone.xml
The standalone.xml file is the default (bare bones) configuration for the JBoss Enterprise Application Platform container. You must edit this file to complete the installation of the ActiveMQ resource adapter.
Note
It is assumed that this file does not already configure the HornetQ messaging system (which would conflict with the ActiveMQ messaging system).
Note
JBoss Enterprise Application Platform can be figured either as a standalone container, using standalone/configuration/standalone.xml, or as a managed domain, using domain/configuration/domain.xml. Throughout this section, we describe explicitly how to configure the standalone container, but it is understood that a similar approach could be used to configure a managed domain.

Steps to install the resource adapter

Perform the following steps to install the Apache ActiveMQ resource adapter into JBoss Enterprise Application Platform (assuming that you will be running the container in standalone mode):
  1. Extract the Apache ActiveMQ community distribution. You can find an archive of the Apache ActiveMQ distribution in the following location:
    InstallDir/extras/apache-activemq-5.9.0.redhat-610379-bin.zip
    Copy to Clipboard Toggle word wrap
    Using a suitable archive utility, extract the preceding archive file to any convenient location on your filesystem. The root of the extracted directory tree is called apache-activemq-5.9.0.redhat-610379 by default.
  2. The ActiveMQ resource adapter archive file can now be found under the /lib/optional sub-directory of the archive extracted in the previous step. Make a copy of the ActiveMQ resource adapter archive file, omitting the version number in the filename. For example, on a UNIX or Linux platform, you can rename the activemq-rar-5.9.0.redhat-610379.rar archive file as follows:
    cd apache-activemq-5.9.0.redhat-610379/lib/optional
    cp activemq-rar-5.9.0.redhat-610379.rar activemq-rar.rar
    Copy to Clipboard Toggle word wrap
    Note
    Renaming the resource adapter archive in this way is not strictly necessary. But because the resource adapter file name appears in the resource adapter configuration, using a versionless filename makes it easier to upgrade the resource adapter at a later date.
  3. Install the ActiveMQ resource adapter by copying the resource adapter archive, activemq-rar.rar, to the relevant JBoss Enterprise Application Platform deployment directory. For example, on a UNIX or Linux platform, you could copy the resource adapter archive to a standalone JBoss Enterprise Application Platform as follows:
    cp activemq-rar.rar EAPInstallDir/standalone/deployments/
    Copy to Clipboard Toggle word wrap
  4. Add the requisite resource adapter configuration to the urn:jboss:domain:resource-adapters:1.1 subsystem in the JBoss Enterprise Application Platform configuration, as follows.
    Open the EAPInstallDir/standalone/configuration/standalone.xml file using a text editor and paste the resource-adapter element from Example 1.1, “ActiveMQ Resource Adapter Configuration in standalone.xml” into the urn:jboss:domain:resource-adapters:1.1 subsystem, as a child of the resource-adapters element.

    Example 1.1. ActiveMQ Resource Adapter Configuration in standalone.xml

    <server xmlns="urn:jboss:domain:1.4">
        ...
        <profile>
            ...
            <subsystem xmlns="urn:jboss:domain:resource-adapters:1.1">
                <resource-adapters>
                    <resource-adapter id="activemq-rar.rar">
                        <archive>
                            activemq-rar.rar
                        </archive>
                        <transaction-support>XATransaction</transaction-support>
                        <config-property name="UserName">
                            defaultUser
                        </config-property>
                        <config-property name="Password">
                            defaultPassword
                        </config-property>
                        <config-property name="ServerUrl">
                            tcp://localhost:61616?jms.rmIdFromConnectionId=true
                        </config-property>
                        <connection-definitions>
                            <connection-definition
                                  class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory"
                                  jndi-name="java:/ConnectionFactory"
                                  enabled="true"
                                  pool-name="ConnectionFactory">
                                <xa-pool>
                                    <min-pool-size>1</min-pool-size>
                                    <max-pool-size>20</max-pool-size>
                                    <prefill>false</prefill>
                                    <is-same-rm-override>false</is-same-rm-override>
                                </xa-pool>
                                <recovery>  
                                    <recover-credential>  
                                        <user-name>defaultUser</user-name>
                                        <password>defaultPassword</password>
                                    </recover-credential>
                                </recovery>
                            </connection-definition>
                        </connection-definitions>
                        <admin-objects>
                            <admin-object
                                  class-name="org.apache.activemq.command.ActiveMQQueue"
                                  jndi-name="java:/queue/HELLOWORLDMDBQueue"
                                  use-java-context="true"
                                  pool-name="HELLOWORLDMDBQueue">
                                <config-property name="PhysicalName">
                                    HELLOWORLDMDBQueue
                                </config-property>
                            </admin-object>
                            <admin-object
                                  class-name="org.apache.activemq.command.ActiveMQTopic"
                                  jndi-name="java:/topic/HELLOWORLDMDBTopic"
                                  use-java-context="true"
                                  pool-name="HELLOWORLDMDBTopic">
                                <config-property name="PhysicalName">
                                    HELLOWORLDMDBTopic
                                </config-property>
                            </admin-object>
                        </admin-objects>
                    </resource-adapter>
                    ...
                </resource-adapters>
            </subsystem>
            ...
        </profile>
        ...
    </server>
    Copy to Clipboard Toggle word wrap
    If your resource adapter archive filename differs from activemq-rar.rar, you must change the content of the archive element in the preceding configuration to match the name of your archive file.
    The values of the UserName and Password configuration properties must be chosen to match the credentials of a valid user in the external broker.
    You might need to change the value of the ServerUrl configuration property to match the actual hostname and port exposed by the external broker.
    Important
    In order to ensure that JMS transactions are integrated correctly, it is essential to include the jms.rmIdFromConnectionId=true option setting on the ServerUrl configuration property and to include the <is-same-rm-override>false</is-same-rm-override> setting in the xa-pool element, as shown above.
    Note
    The JMS administrative objects defined in the admin-objects element do not need to be defined yet. They serve as examples to show how you can define administrative objects for the ActiveMQ resource adapter (they are used later in the message-driven bean demonstration).
  5. Add the requisite message driven bean configuration to the urn:jboss:domain:ejb3:1.4 subsystem in the JBoss Enterprise Application Platform configuration.
    Open the EAPInstallDir/standalone/configuration/standalone.xml file using a text editor and paste the mdb element from Example 1.2, “Message Driven Bean Configuration in standalone.xml” into the urn:jboss:domain:ejb3:1.4 subsystem.

    Example 1.2. Message Driven Bean Configuration in standalone.xml

    <server xmlns="urn:jboss:domain:1.4">
        ...
        <profile>
            ...
            <subsystem xmlns="urn:jboss:domain:ejb3:1.4">
                ...
                <mdb>
                    <resource-adapter-ref resource-adapter-name="activemq-rar.rar"/>
                    <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
                </mdb>
                <pools>
                    <bean-instance-pools>
                        <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                        <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                    </bean-instance-pools>
                </pools>
                ...
            </subsystem>
            ...
        </profile>
        ...
    </server>
    Copy to Clipboard Toggle word wrap
  6. Before starting the broker, check the broker configuration to make sure that there are valid user credentials defined in the broker's InstallDir/etc/users.properties file. For example, to match the UserName and Password credentials configured in Example 1.1, “ActiveMQ Resource Adapter Configuration in standalone.xml”, the users.properties file should contain an entry like the following:
    defaultUser=defaultPassword,admin
    Copy to Clipboard Toggle word wrap
  7. Start the external A-MQ broker. For example, on a UNIX or Linux platform, you can start the JBoss A-MQ broker instance as follows:
    cd InstallDir/bin
    ./amq
    Copy to Clipboard Toggle word wrap
  8. Start the standalone instance of JBoss Enterprise Application Platform. For example, on a UNIX or Linux platform, you can start the standalone instance as follows:
    cd EAPInstallDir/bin
    ./standalone.sh
    Copy to Clipboard Toggle word wrap

Resource adapter configuration

In the configuration shown in Example 1.1, “ActiveMQ Resource Adapter Configuration in standalone.xml”, you use the config-property element to set resource adapter properties. The ActiveMQ resource adapter supports the following basic properties:
UserName
(Optional) Specifies the client username when connecting to the JBoss A-MQ broker (not required in this example, because the JBoss A-MQ broker configuration does not enable authentication).
Password
(Optional) Specifies the client password when connecting to the JBoss A-MQ broker (not required in this example, because the JBoss A-MQ broker configuration does not enable authentication).
ServerUrl
Specifies the URL used to connect to the JBoss A-MQ broker instance. This value must match one of the endpoints specified by a transportConnector element in the JBoss A-MQ broker configuration.
BrokerXmlConfig
(Optional) Specifies the location of an embedded broker's XML configuration file. To specify a location on the file system, use the format, xbean:file://AbsolutePath, where the path, AbsolutePath, should be specified as an absolute pathname.
UseInboundSession
(Optional) Sets a flag that specifies whether outbound connections should reuse the inbound connection's session for sending messages (useful for connections going through a firewall). Defaults to false.
Clientid
(Optional) Specifies a JMS client ID, which the resource adapter uses for the connection from the JBoss Enterprise Application Platform container.

JBoss A-MQ broker configuration

Most of the options for customizing the ActiveMQ resource adapter are provided by the JBoss A-MQ broker configuration file, at the following location:
InstallDir/etc/activemq.xml
Copy to Clipboard Toggle word wrap
This configuration file supports a huge range of features and settings which are beyond the scope of this guide. To learn more about JBoss A-MQ broker configuration, see the following guides from the Red Hat JBoss A-MQ documentation library:
  • Configuring Broker Persistence
  • Tuning Guide
  • Security Guide
  • XML Configuration Reference
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat