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 ...
随机推荐
- ElasticSearch 索引模块——全文检索
curl -XPOST http://master:9200/djt/user/3/_update -d '{"doc":{"name":"我们是中国 ...
- 你的GAN训练得如何--GAN 的召回率(多样性)和精确率(图像质量)方法评估
生成对抗网络(GAN)是当今最流行的图像生成方法之一,但评估和比较 GAN 产生的图像却极具挑战性.之前许多针对 GAN 合成图像的研究都只用了主观视觉评估,一些定量标准直到最近才开始出现.本文认为现 ...
- Python - Django - ORM 实例(二)
在 app01/models.py 中添加 Book 类对象表 from django.db import models # Create your models here. # 出版社 class ...
- 显式锁(三)读写锁ReadWriteLock
前言: 上一篇文章,已经很详细地介绍了 显式锁Lock 以及 其常用的实现方式- - ReetrantLock(重入锁),本文将介绍另一种显式锁 - - 读写锁ReadWriteLock. ...
- 异步与websocket
异步与WebSockets 知识点 理解同步与异步执行过程 理解异步代码的回调写法与yield写法 Tornado异步 异步Web客户端AsyncHTTPClient tornado.web.asyn ...
- c++官方文档-模版类
#include <iostream> using namespace std; template<class T> class MyPair { private: T t[] ...
- 0_Simple__simpleMultiCopy
利用 CUDA 的 Overlap 特性同时进行运算和数据拷贝来实现加速. ▶ 源代码.使用 4 个流一共执行 10 次 “数据上传 - 内核计算 - 数据下载” 过程,记录使用时间. #includ ...
- saltstack安装配置及常用命令
1.salt安装及配置详解 https://www.cnblogs.com/lgeng/p/6567424.html centos7配置: https://www.jianshu.com/p/4c91 ...
- Delphi 浏览器WebBrowser
WebBrowser1.Navigate(URL); while WebBrowser1.busy do Application.ProcessMessages; while WebBrowser1. ...
- 定制sudo的密码保持时间以及如何不需要密码
由于每次sudo什么都要输入密码..好麻烦.所以我要把它的密码记住时间修改一下,变得长一点. 先输入命令 vim /etc/sudoers找到下面行 Defaults env_reset 改变此行为下 ...