---
title: "WAS+MQ Refer"
author: "sqiutz"
date: "2010-04-26T15:44:25Z"
tags: []
categories: ["企业架构"]
slug: "was-mq-refer"
draft: false
lastmod: "2010-04-26T15:45:01Z"
id: 653308
url: "https://sqiutz.iteye.com/blog/653308"
---

准备 ：确认WebSphere MQ主机和WebSphere Application Server主机可以互相通过主机名ping通。

&lt;script type="text/javascript"&gt; &lt;/script&gt; &lt;script src="http://pagead2.googlesyndication.com/pagead/show\_ads.js" type="text/javascript"&gt; &lt;/script&gt;

第一步：在WebSphere MQ主机上面安装和配置WebSphere MQ；增加一个操作系统用户(比如mquser)，并把他添加到组mqm中。

第二步：使用如下命令创建队列管理器，队列，通道   
\--create q manager   
crtmqm -q SPC   
\--WebSphere MQ 队列管理器已创建。   
\--创建或替换 SPC 的缺省对象。   
\--缺省对象统计：31 个已创建。0 个已替换。0 个已失败。   
\--正在完成设置。   
\--设置完成。

--start the q mamanger   
strmqm SPC   
\--WebSphere MQ 队列管理器‘SPC’已启动。

--run mq command line   
runmqsc SPC   
\--5724-B41 (C) Copyright IBM Corp. 1994, 2002.  ALL RIGHTS RESERVED.   
\--启动队列管理器 SPC 的 MQSC。

--define queue   
def QL('spcQ')   
\--AMQ8006: WebSphere MQ 队列已创建。

DEF CHL('JAVA.CHANNEL') CHLTYPE(SVRCONN) TRPTYPE(TCP)   
\--AMQ8014: WebSphere MQ 通道已创建。

--start mq listener for q manager, listening on tcp port 1414, ready for remote access   
runmqlsr -m SPC -t tcp -p 1414

第三步：在WebSphere Application Server主机上安装WebSphere MQ Client, WebSphere MQ Java支持

第四步：配置WebSphere的变量   
在WebSphere管理控制台[http://localhost:9090/admin/](http://localhost:9090/admin/)左边栏目中选择 环境-&gt;管理WebSphere变量   
确认MQ\_INSTALL\_ROOT变量值，比如C:/PROGRA~1/IBM/WEBSPH~1   
确认MQJMS\_LIB\_ROOT变量值，比如${MQ\_INSTALL\_ROOT}/java/lib

第五步：添加一个认证别名用来访问远程MQ   
在WebSphere管理控制台左边栏目中选择 安全性-&gt;JAAS配置-&gt;J2C 认证数据条目   
新建一个J2C 认证数据条目，输入WebSphere MQ主机中mqm组里面的用户，比如第一步中创建的用户mquser

第六步：配置WebSphere MQ 队列连接工厂   
在WebSphere管理控制台左边栏目中选择 资源-&gt;WebSphere MQ JMS提供程序   
选择 WebSphere MQ 队列连接工厂，新建，输入参数   
名称: qmanager   
JNDI名: jms/spcQCF   
组件受管认证别名: yangj/mquser   
容器受管的认证别名: yangj/mquser   
Queue Manager: SPC   
主机: spcm10   
端口: 1414   
传输类型:CLIENT   
通道: JAVA.CHANNEL   
CCSID: 1381

第七步：配置WebSphere MQ 队列目的地   
在WebSphere管理控制台左边栏目中选择 资源-&gt;WebSphere MQ 队列目的地   
选择 WebSphere MQ 队列目的地，新建，输入参数   
名称: queue   
JNDI名：jms/spcQ   
基本队列名：spcQ

第八步：重新启动WAS   
手工编写一个简单的JMS测试程序，放在C:\\WebSphere\\AppServer\\installedApps\\yangj\\DefaultApplication.ear\\DefaultWebApplication.war下面通过[http://localhost:9080/JMSSenderInputPage.jsp](http://localhost:9080/JMSSenderInputPage.jsp)访问就可以了。

&lt;script type="text/javascript"&gt; &lt;/script&gt; &lt;script src="http://pagead2.googlesyndication.com/pagead/show\_ads.js" type="text/javascript"&gt; &lt;/script&gt;