此内容没有您所选择的语言版本。
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
InstallDir/extras/apache-activemq-5.9.0.redhat-610379-bin.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
apache-activemq-5.9.0.redhat-610379/lib/optionalCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 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/
http://repo.fusesource.com/nexus/content/groups/public/org/apache/activemq/activemq-rar/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Download the.rararchive 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.xmlfile 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.NoteIt 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):
- 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
InstallDir/extras/apache-activemq-5.9.0.redhat-610379-bin.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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 calledapache-activemq-5.9.0.redhat-610379by default. - The ActiveMQ resource adapter archive file can now be found under the
/lib/optionalsub-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 theactivemq-rar-5.9.0.redhat-610379.rararchive 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
cd apache-activemq-5.9.0.redhat-610379/lib/optional cp activemq-rar-5.9.0.redhat-610379.rar activemq-rar.rarCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteRenaming 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. - 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/
cp activemq-rar.rar EAPInstallDir/standalone/deployments/Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the requisite resource adapter configuration to the
urn:jboss:domain:resource-adapters:1.1subsystem in the JBoss Enterprise Application Platform configuration, as follows.Open theEAPInstallDir/standalone/configuration/standalone.xmlfile using a text editor and paste theresource-adapterelement from Example 1.1, “ActiveMQ Resource Adapter Configuration in standalone.xml” into theurn:jboss:domain:resource-adapters:1.1subsystem, as a child of theresource-adapterselement.Example 1.1. ActiveMQ Resource Adapter Configuration in standalone.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If your resource adapter archive filename differs fromactivemq-rar.rar, you must change the content of thearchiveelement in the preceding configuration to match the name of your archive file.The values of theUserNameandPasswordconfiguration properties must be chosen to match the credentials of a valid user in the external broker.You might need to change the value of theServerUrlconfiguration property to match the actual hostname and port exposed by the external broker.ImportantIn order to ensure that JMS transactions are integrated correctly, it is essential to include thejms.rmIdFromConnectionId=trueoption setting on theServerUrlconfiguration property and to include the<is-same-rm-override>false</is-same-rm-override>setting in thexa-poolelement, as shown above.NoteThe JMS administrative objects defined in theadmin-objectselement 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). - Add the requisite message driven bean configuration to the
urn:jboss:domain:ejb3:1.4subsystem in the JBoss Enterprise Application Platform configuration.Open theEAPInstallDir/standalone/configuration/standalone.xmlfile using a text editor and paste themdbelement from Example 1.2, “Message Driven Bean Configuration in standalone.xml” into theurn:jboss:domain:ejb3:1.4subsystem.Example 1.2. Message Driven Bean Configuration in standalone.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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.propertiesfile. For example, to match theUserNameandPasswordcredentials configured in Example 1.1, “ActiveMQ Resource Adapter Configuration in standalone.xml”, theusers.propertiesfile should contain an entry like the following:defaultUser=defaultPassword,admin
defaultUser=defaultPassword,adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 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
cd InstallDir/bin ./amqCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 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
cd EAPInstallDir/bin ./standalone.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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
transportConnectorelement 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
InstallDir/etc/activemq.xml
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