24.8. 部署 WebSphere MQ 资源适配器
WebSphere MQ 是 IBM 的面向消息中间件(Messaging Oriented Middleware,MOM),它允许分布式系统上的应用程序彼此通讯。这是通过消息和消息队列来实现的。WebSphere MQ 负责递送消息到消息队列并用消息频道传输数据到其他队列管理者。关于 WebSphere MQ 的更多信息,请参考 WebSphere MQ。
本节涵盖在 JBoss EAP 6 里部署和配置 WebSphere MQ 资源适配器的步骤。您可以手动编辑配置文件来完成,也可以通过管理 CLI 或使用基于 Web 的管理控制台来完成。
在开始之前,您必需检验 WebSphere MQ 资源适配器的版本并理解一些 WebSphere MQ 配置属性。
- WebSphere MQ 资源适配器是作为 Resource Archive (RAR) 文件(
wmq.jmsra-VERSION.rar)提供的。您必须使用7.5.0.0或之后的版本。 - 您必须了解下列 WebSphere MQ 配置属性。关于这些属性的细节,请参考 WebSphere MQ 产品文档。
- MQ.QUEUE.MANAGER:WebSphere MQ 队列管理者的名称
- MQ.PORT:用来连接 WebSphere MQ 队列管理者的主机名
- MQ.PORT:用来连接 WebSphere MQ 队列管理者的服务器频道
- MQ.QUEUE.NAME:目标队列的名称
- MQ.TOPIC.NAME:目标主题的名称
- MQ.PORT:用来连接 WebSphere MQ 队列管理者的端口
- MQ.CLIENT:传输类型
- 对于转出连接,您也必须熟悉下列配置属性:
- MQ.CONNECTIONFACTORY.NAME:提供连接给远程系统的连接工厂实例的名称
注意
过程 24.8. 手动部署资源适配器
- 如果您需要 WebSphereMQ 资源适配器支持事务,您必须重新打包
wmq.jmsra-VERSION.rar归档,使其包含mqetclient.jar。您可以使用下列命令:[user@host ~]$
请用正确的版本号码替换 VERSION。jar -uf wmq.jmsra-VERSION.rar mqetclient.jar - 复制
wmq.jmsra-VERSION.rar文件到EAP_HOME/standalone/deployments/目录。 - 在服务器配置文件里添加资源适配器。
- 在编辑器里打开
EAP_HOME/standalone/configuration/standalone-full.xml文件。 - 在配置文件里找到
urn:jboss:domain:resource-adapters子系统。 - 如果没有为这个子系统定义资源适配器,请首先替换:
<subsystem xmlns="urn:jboss:domain:resource-adapters:1.1"/>
使用下列内容:<subsystem xmlns="urn:jboss:domain:resource-adapters:1.1"> <resource-adapters> <!-- <resource-adapter> configuration listed below --> </resource-adapters> </subsystem> - 资源适配器的配置依赖您是否需要事务支持和恢复。如果您不需要事务支持,请选择下面的第一个配置步骤。如果您需要事务支持,请选择第二个配置步骤。
- 对于非事务性部署,请用下列内容替换
<!-- <resource-adapter> configuration listed below -->:<resource-adapter> <archive> wmq.jmsra-VERSION.rar </archive> <transaction-support>NoTransaction</transaction-support> <connection-definitions> <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME" pool-name="MQ.CONNECTIONFACTORY.NAME"> <config-property name="hostName"> MQ.HOST.NAME </config-property> <config-property name="port"> MQ.PORT </config-property> <config-property name="channel"> MQ.CHANNEL.NAME </config-property> <config-property name="transportType"> MQ.CLIENT </config-property> <config-property name="queueManager"> MQ.QUEUE.MANAGER </config-property> <security> <security-domain>MySecurityDomain</security-domain> </security> </connection-definition> </connection-definitions> <admin-objects> <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/MQ.QUEUE.NAME" pool-name="MQ.QUEUE.NAME"> <config-property name="baseQueueName"> MQ.QUEUE.NAME </config-property> <config-property name="baseQueueManagerName"> MQ.QUEUE.MANAGER </config-property> <admin-object class-name="com.ibm.mq.connector.outbound.MQTopicProxy" jndi-name="java:jboss/MQ.TOPIC.NAME" pool-name="MQ.TOPIC.NAME"> <config-property name="baseTopicName"> MQ.TOPIC.NAME </config-property> <config-property name="brokerPubQueueManager"> MQ.QUEUE.MANAGER </config-property> </admin-object> </admin-object> </admin-objects> </resource-adapter>请确保用 RAR 名称里的实际版本替换 VERSION。 - 对于事务性部署,请用下列内容替换
<!-- <resource-adapter> configuration listed below -->:<resource-adapter> <archive> wmq.jmsra-VERSION.rar </archive> <transaction-support>XATransaction</transaction-support> <connection-definitions> <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME" pool-name="MQ.CONNECTIONFACTORY.NAME"> <config-property name="hostName"> MQ.HOST.NAME </config-property> <config-property name="port"> MQ.PORT </config-property> <config-property name="channel"> MQ.CHANNEL.NAME </config-property> <config-property name="transportType"> MQ.CLIENT </config-property> <config-property name="queueManager"> MQ.QUEUE.MANAGER </config-property> <security> <security-domain>MySecurityDomain</security-domain> </security> <recovery> <recover-credential> <user-name>USER_NAME</user-name> <password>PASSWORD</password> </recover-credential> </recovery> </connection-definition> </connection-definitions> <admin-objects> <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/MQ.QUEUE.NAME" pool-name="MQ.QUEUE.NAME"> <config-property name="baseQueueName"> MQ.QUEUE.NAME </config-property> <config-property name="baseQueueManagerName"> MQ.QUEUE.MANAGER </config-property> </admin-object> <admin-object class-name="com.ibm.mq.connector.outbound.MQTopicProxy" jndi-name="java:jboss/MQ.TOPIC.NAME" pool-name="MQ.TOPIC.NAME"> <config-property name="baseTopicName"> MQ.TOPIC.NAME </config-property> <config-property name="brokerPubQueueManager"> MQ.QUEUE.MANAGER </config-property> </admin-object> </admin-objects> </resource-adapter>请确保用 RAR 名称里的实际版本替换 VERSION。您也必须用有效的用户名和密码替换 USER_NAME 和 PASSWORD。注意
为了支持事务, <transaction-support> 元素要设置为XATransaction。为了支持 XA 恢复,<recovery> 元素要添加至连接定义里。
- 如果您想将 JBoss EAP 6 里的默认 EJB3 消息系统 HornetQ 修改为 WebSphere MQ,请这样修改
urn:jboss:domain:ejb3:1.2子系统:替换:<mdb> <resource-adapter-ref resource-adapter-name="hornetq-ra"/> <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> </mdb>为:<mdb> <resource-adapter-ref resource-adapter-name="wmq.jmsra-VERSION.rar"/> <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> </mdb>请确保用 RAR 名称里的实际版本替换 VERSION。
过程 24.9. 修改 MDB 代码来使用资源适配器
- 在 MDB 代码里这样配置 ActivationConfigProperty 和 ResourceAdapter
@MessageDriven( name="WebSphereMQMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"), @ActivationConfigProperty(propertyName = "hostName", propertyValue = "MQ.HOST.NAME"), @ActivationConfigProperty(propertyName = "port", propertyValue = "MQ.PORT"), @ActivationConfigProperty(propertyName = "channel", propertyValue = "MQ.CHANNEL.NAME"), @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "MQ.QUEUE.MANAGER"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "MQ.QUEUE.NAME"), @ActivationConfigProperty(propertyName = "transportType", propertyValue = "MQ.CLIENT") }) @ResourceAdapter(value = "wmq.jmsra-VERSION.rar") @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public class WebSphereMQMDB implements MessageListener { }请确保用 RAR 名称里的实际版本替换 VERSION。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.