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 ...
随机推荐
- 给iOS开发新手送点福利,简述UIDatePicker的用法
1.Locale 设置DatePicker的地区,即设置DatePicker显示的语言. 1.跟踪所有可用的地区,取出想要的地区 NSLog(@"%@", [NSLocale av ...
- JAVA中关于set()和get()方法的理解及使用
对于JAVA初学者来说,set和get这两个方法似乎已经很熟悉了,这两个方法是JAVA变成中的基本用法,也是出现频率相当高的两个方法. 为了让JAVA初学者能更好的理解这两个方法的使用和意义,今天笔者 ...
- 解决Visual Studio “无法导入以下密钥文件”的错误
错误1无法导入以下密钥文件: Common.pfx.该密钥文件可能受密码保护.若要更正此问题,请尝试再次导入证书,或手动将证书安装到具有以下密钥容器名称的强名称 CSP: VS_KEY_ 1110Co ...
- UVA-673-栈-水题
题意: 检测括号是否匹配,注意有空格 #include<stdio.h> #include<iostream> #include <strstream> #incl ...
- as3 对于加载进来多层swf缩放操作
//swf实际尺寸 var oldWidth:Number = frameLder.contentLoaderInfo.content.width; var oldHeight:Number = fr ...
- 淘宝开源系统监控工具Tsar
Tsar是淘宝开发的一个非常好用的系统监控工具,在淘宝内部大量使用 它不仅可以监控CPU.IO.内存.TCP等系统状态,也可以监控Apache,Nginx/Tengine,Squid等服务器状态 ...
- java流输入输出
java读取txt文件内容.可以作如下理解: 首先获得一个文件句柄.File file = new File(); file即为文件句柄.两人之间连通电话网络了.接下来可以开始打电话了. 通过这条 ...
- express + mongodb 搭建一个简易网站(二)
express + mongodb 搭建一个简易网站 (二) 在搭建网站(一)中,实现了简单的路由功能,这离一个完整的网站还差的有点远,继续撸代码吧. 1.首先在根目录下新建一个views文件夹,用来 ...
- python,遍历文件的方法
在做验证码识别时,识别时需要和库里的图片对比,找到最接近的那个图片,然后就行到了用与图片一致的字符命名,获取文件的名称,去将图片的名称读出来作为验证码.以下是我通过网上的资料总结的三种文件遍历的方式, ...
- dhtmlx uploader使用
前端:{type : "upload", mode : "html4", name : "importFile", inputWidth : ...