Connecting to MQSeries with .NET
By connecting to MQSeries withing a .NET application, first it has to be done is to install MQ Series client at the machine which will host the application.
To do that, you can obtain for example the trial
version of WebSphere MQ. During installation first the prerequisites are
checked. Unfortunately if you try to install the package at Windows
Vista, no wonder, it will just fail, because the operative system is
currently not supported by the setup. The good thing is that this
requirement just can be ignored. Clearly that means, just install all
other prerequisites and proceed with installation.
If you
installed the Web Sphere at the local machine or somewhere in the
windows environment with active directory infrastructure, there is a
group named "MQM". The windows user who is running your .NET application
has to be member of this group in order to be able to connect to MQ. In
that case following code can be used to establish the connection and to
put one simple message in the queue:
|
[TestMethod] queueMessage.Format = MQC.MQFMT_STRING; MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions(); } |
This
code connects to the MQ manager "QM_testmgr" by using of channel
"mychannel" hostet at the specified IP address. After executing you can
see the message in the queue "default".
Assume you want now to
connect to some remote machine. If you use this code the connection to
the queueManager will fail with reason code 2035 = Not Authorized. To
avoid this problem the MCA of the remote channel
has to be
explicitly set. To do that, open the MQ Explorer go to channel
properties and open the tab MCA. Then enter the name of the user who is
authorized to connect. In the example bellow, I used the user "mqm".

Now the code in the .NET application has to be slightly changed as shown in the next example:
|
[TestMethod] MQQueueManager queueManager = new MQQueueManager(m_QueueManager, props); MQQueue queue = queueManager.AccessQueue("default", queueMessage.Format = MQC.MQFMT_STRING; MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions(); } |
At
this point is important, that specified username "mqm" has to match the
name set in the MCA-tab. Additionally it is interesting, that the
password does not have to match user's password, but it has to be
specified as property.
If password property is not specified at all, the initialization will crash with a "null reference error".
Last
but not least. If you do not want to specify the username in your code,
means you would like to use the first code example, there also one a
little confusing possibility. Create some other user and put in the MQM
group. The name of this user should be the same as the name of user who
will run the .NET application. In this case if the name of interactive
user (who is running the application) matches the name of the user
member of MQM group at the remote system (this does not have to be
necessarily windows system) you will not need the provide credential
properties (MQC.USER_ID_PROPERTY and MQC.PASSWORD_PROPERTY) and MCA name may be empty.
By troubleshooting following very useful link contains the list of all reason codes.
Connecting to MQSeries with .NET的更多相关文章
- Error connecting to database [Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)]
参照 http://stackoverflow.com/questions/4448467/cant-connect-to-local-mysql-server-through-socket-var- ...
- 两主机搭建MySQL主从复制后,show slave status显示:Last_IO_Error: error connecting to master ……
两台主机A.B搭建mysql主从复制关系(A为master,B为slave)后,在slave上执行show slave status,结果中显示Last_IO_Error: error connect ...
- [nginx] connect() failed (111: Connection refused) while connecting to upstream, client: 101.18.123.107, server: localhost,
nginx一直报错, 2016/12/02 10:23:19 [error] 1472#0: *31 connect() failed (111: Connection refused)while c ...
- connect() failed (111: Connection refused) while connecting to upstream
配置好lamp后,在浏览器中运行程序后,出现上面的错误. 转自:http://www.xuejiehome.com/blread-1828.html I'm experiencing 502 gate ...
- Ipython console in Spyder stuck on “connecting to kernel”
简短地记录下,今天排除的spyder的BUG, 现象:打开Spyder时其他正常,但是Ipython console 不能正常获取到kernel,一直转圈,显示“connecting to kerne ...
- socket() failed (13: Permission denied) while connecting to upstream
/*************************************************************************** * socket() failed (13: ...
- Connecting Physics Bodies
[Connecting Physics Bodies] The kinds of joints you can create in Sprite Kit. You add or remove join ...
- 【转载】MySQL 5.6主从Slave_IO_Running:Connecting/error connecting to master *- retry
原文地址:MySQL 5.6主从Slave_IO_Running:Connecting/error connecting to master *- retry 作者:忆雨林枫 刚配置的MySQL主从, ...
- CCS 5 XDS100 仿真连接错误Error connecting to the target【瓦特芯笔记】
问题现象:在点击仿真是出现连接错误: Error connecting to the target: (Error -151 @ 0x0) One of the FTDI driver funct ...
随机推荐
- ExtJS的数据模型
给大家介绍一下ExtJS的组件模型. 常见的Ajax的开发流程: 1.定义URL,metod,params 2.开发后台 接收JSON/XML数据 返回JSON/XML数据 3.前台回调 4.显示到 ...
- 省市县_me
# question 11import astfrom functools import reduce def file_read(): with open('D:\\pytharm\\ji ...
- 中国移动基于ARM/x86服务器的Ceph性能对比
2018年11月17日,Ceph中国行首次走进杭州,万众期待的杭州站沙龙如期而至,虽然杭州已经开始降温,阵雨不断,但活动现场依然热度爆表,杭州各大IT公司的从业人员和Ceph爱好者纷纷而来. 中国移动 ...
- 文件系统性能测试--iozone
iozone 一个文件系统性能评测工具,可以测试Read, write, re-read,re-write, read backwards, read strided, fread, fwrite, ...
- 原生socket请求url获取状态码、消息报头、响应正文
需求: (1)使用socket及ssl模块写通用的web客户端 (2)向服务器发起请求 (3)接受响应内容并解析出状态码.消息报头.响应正文 (4)最核心的函数: 输入一个url,返回状态码.消息报头 ...
- selenium+python自动化95-弹出框死活定位不到
前言 部分小伙伴学了selenium的alert后,就不管啥弹出框都去用alert,这是行不通的,看到弹出框,先要确定是不是alert,是才能用,不是的话肯定不能用. 有些弹出框是div层,这种跟平常 ...
- ftps加密服务器
咱不废话,理论不提,直接上步骤,[linux下的ftps服务器系统搭建步骤如下,按此步骤,即可搭建ftps服务器系统] 1.[安装vsftpd] yum -y install vsftpd 2.[安装 ...
- 15. "wm_concat"_数据库中将查询出来的多条记录中的某个字段用","拼接起来
例子: select wm_concat(roleid) from lbmember where userid = ? 值的形式:1,2,3 下面是把1,2,3转换为1;2;3select repla ...
- three3D地图设置两点之间的连线
点:可以用THREE.Vector3D来表示 现在来看看怎么定义个点,假设有一个点x=4,y=8,z=9.你可以这样定义它: var point1 = new THREE.Vecotr3(4,8,9) ...
- leetcode496
public class Solution { public int[] NextGreaterElement(int[] findNums, int[] nums) { var list = new ...