IBM MQ Server Setup 用于创建 .NET Client 使用的 CCDT 文件



我需要使用 CCDT 文件让 MQ.NET 客户端连接到 MQ 服务器,两者都在本地运行,但出现以下错误。

IBM.WMQ.MQException: MQRC_Q_MGR_NAME_ERROR CompCode: 2, Reason: 2058

请在下面找到服务器设置和 MQ.NET 客户端。

服务器设置

我按照以下链接设置并创建了CCDT文件:

使用 IBM MQ 资源管理器设置服务器

服务器连接通道:本地。定义。斯弗康

MCA 用户 ID:我尝试省略或提供它。无论是否是 mqm 的成员。

使用 IBM MQ 资源管理器设置客户机

Clinet channe:本地。定义。斯弗康

队列管理器名称:本地 QM

连接名称: 192.168.1.9 (1415)

192.168.1.9 是本地主机地址

1415是队列管理器,LocalQM,TCP端口。

IBM MQ.NET

代码从这里开始如下

MQQueueManager qm = null;
System.Environment.SetEnvironmentVariable("MQCHLLIB", "C:\ProgramData\IBM\MQ\qmgrs\LocalQM\@ipcc");
System.Environment.SetEnvironmentVariable("MQCHLTAB", "AMQCLCHL.TAB");
try
{
Hashtable props = new Hashtable();
props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
qm = new MQQueueManager("LocalQM",props);
MQQueue queue1 = qm.AccessQueue("LocalQueue", MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING);
MQMessage msg = new MQMessage();
msg.WriteUTF("Hello this message is from .net client");
queue1.Put(msg);
queue1.Close();
qm.Disconnect();
}
catch (Exception ex)
{
Console.Write(ex);
}

Windows 10 上的 IBM MQ V8

MQ.NET Windows 10 上的客户端 V8

创建客户端通道定义表

将客户端通道定义表与 .NET 配合使用

更新

如果我在不使用 CCDT 的情况下更改为下面,它可以工作。

var properties = new Hashtable
{
{MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED },         
{ MQC.HOST_NAME_PROPERTY, "192.168.1.9" }, //"localhost" },
{ MQC.PORT_PROPERTY, "1415"},
{ MQC.CHANNEL_PROPERTY, "LOCAL.DEF.SVRCONN" },
{MQC.USER_ID_PROPERTY, "xxx" },  //usrename
{MQC.PASSWORD_PROPERTY, "xxx" }  //password
};
_queueManager = new MQQueueManager(_queueManagerName, properties);

更新 2我将队列管理器更改为本地QM

C:Users'#.lpsource>SET MQCHLLIB=C:ProgramDataIBMMQqmgrsLocalQM@ipcc
C:Users'#.lpsource>SET MQCHLTAB=AMQCLCHL.TAB
C:Users'#.lpsource>echo DIS CHL(LOCAL.DEF.SVRCONN) CHLTYPE(CLNTCONN) ALL | runmqsc -n
5724-H72 (C) Copyright IBM Corp. 1994, 2015.
Starting local MQSC for 'AMQCLCHL.TAB '.
1 : DIS CHL(LOCAL.DEF.SVRCONN) CHLTYPE(CLNTCONN) ALL
AMQ8414: Display Channel details.
CHANNEL(LOCAL.DEF.SVRCONN)              CHLTYPE(CLNTCONN)
AFFINITY(PREFERRED)                     ALTDATE(2018-04-16)
ALTTIME(22.16.03)                       CERTLABL( )
CLNTWGHT(0)                             COMPHDR(NONE)
COMPMSG(NONE)                           CONNAME(192.168.1.9 (1415))
DEFRECON(NO)                            DESCR( )
HBINT(300)                              KAINT(AUTO)
LOCLADDR( )                             MAXMSGL(4194304)
MODENAME( )                             PASSWORD( )
QMNAME(LocalQM)                         RCVDATA( )
RCVEXIT( )                              SCYDATA( )
SCYEXIT( )                              SENDDATA( )
SENDEXIT( )                             SHARECNV(10)
SSLCIPH( )                              SSLPEER( )
TPNAME( )                               TRPTYPE(TCP)
USERID( )
No commands have a syntax error.
C:Users'#.lpsource>

更新 3:MQRC_NOT_AUTHORIZED未解决

我变了

  1. 192.168.1.9 (1415) -> 192.168.1.9(1415)
  2. 把AMQCLCHL。TAB 也到 C:\ProgramData\IBM\MQ(我不知道为什么这可能不正确,因为日志文件上的错误:

    AMQ9518:文件 'C:\ProgramData\IBM\MQ\AMQCLCHL。未找到 TAB。

)

3 我试过了 MCA 用户 ID ->

1 个 MQL 客户端,他们是 MQM 的成员

2 个不是 MQM 成员的 MQLClient

3 空

但仍然有错误。以下是 3.1 的异常和错误

IBM.WMQ.MQException: MQRC_NOT_AUTHORIZED
----- cmqxrsrv.c : 2356 -------------------------------------------------------
17/04/2018 23:50:44 - Process(1848.16) User(SYSTEM) Program(amqzlaa0.exe)
Host(APPLE) Installation(Installation1)
VRMF(8.0.0.5) QMgr(LocalQM)
AMQ5540: Application 'binDebugProducer.exe' did not supply a user ID
and password
EXPLANATION:
The queue manager is configured to require a user ID and password, but none was
supplied.
ACTION:
Ensure that the application provides a valid user ID and password, or change
the queue manager configuration to OPTIONAL to allow applications to connect
which have not supplied a user ID and password. 
----- amqzfuca.c : 4311 -------------------------------------------------------
17/04/2018 23:50:44 - Process(1848.16) User(SYSTEM) Program(amqzlaa0.exe)
Host(APPLE) Installation(Installation1)
VRMF(8.0.0.5) QMgr(LocalQM)
AMQ5541: The failed authentication check was caused by the queue manager
CONNAUTH CHCKCLNT(REQDADM) configuration.
EXPLANATION:
The user ID 'mqclient' and its password were checked because the user ID is
privileged and the queue manager connection authority (CONNAUTH) configuration
refers to an authentication information (AUTHINFO) object named
'SYSTEM.DEFAULT.AUTHINFO.IDPWOS' with CHCKCLNT(REQDADM). 
This message accompanies a previous error to clarify the reason for the user ID
and password check.
ACTION:
Refer to the previous error for more information. 
Ensure that a password is specified by the client application and that the
password is correct for the user ID. The authentication configuration of the
queue manager connection determines the user ID repository. For example, the
local operating system user database or an LDAP server. 
To avoid the authentication check, you can either use an unprivileged user ID
or amend the authentication configuration of the queue manager. You can amend
the CHCKCLNT attribute in the CHLAUTH record, but you should generally not
allow unauthenticated remote access. 
-------------------------------------------------------------------------------
17/04/2018 23:50:45 - Process(14900.9) User(SYSTEM) Program(amqrmppa.exe)
Host(APPLE) Installation(Installation1)
VRMF(8.0.0.5) QMgr(LocalQM)
AMQ9557: Queue Manager User ID initialization failed for 'mqclient'.
EXPLANATION:
The call to initialize the User ID 'mqclient' failed with CompCode 2 and Reason
2035.
ACTION:
Correct the error and try again. 
----- cmqxrsrv.c : 2356 -------------------------------------------------------

OP 在更新 2 中的问题中添加了以下信息:

  1. SET MQCHLLIB=C:ProgramDataIBMMQqmgrsQM1@ipcc
  2. SET MQCHLTAB=AMQCLCHL.TAB
  3. echo DIS CHL(LOCAL.DEF.SVRCONN) CHLTYPE(CLNTCONN) ALL | runmqsc -n

我看到 CCDT 可能存在两个问题:

  1. 在 IP 和左括号之间的CONNAME中有一个空格。 这可能会导致 MQ 忽略端口 1415 并使用默认端口 1414,它也可能忽略空间,这可能不是问题,我从未用空格进行测试。

    COMPMSG(NONE)                           CONNAME(192.168.1.9 (1415))
    
  2. CLNTCONN通道的QMNAME应与您在调用new MQQueueManager中指定的内容相匹配,因此这应该说QM1不是LocalQM,这可能是您2058错误的直接原因,但是一旦您修复#2,#1也可能导致问题。

    QMNAME(LocalQM)                         RCVDATA( )
    

QMNAME 还有其他用途,您可以在其中指定组名或空白。 请参阅我对"使用 JMS 中的 CCDT 文件连接到 IBM MQ"的回答 "以获取更多详细信息。 答案与 JMS 有关,但为setQueueManager提供的信息将与调用new MQQueueManager的第一个参数相同。

一般来说,原因码 2058 (MQRC_Q_MGR_NAME_ERROR) 表示您的队列管理器名称无效,或者服务器没有该特定队列管理器。 检查您输入的队列管理器名称的拼写。 此外,队列管理器名称区分大小写(例如 MQA1 与 mqa1 不同)。

此外,每个队列管理器都有自己的端口 #。 即 1414、1415、1416 等。 因此,如果该服务器上运行着 1 个以上的队列管理器,请确保使用的是正确的端口。

System.Environment.SetEnvironmentVariable("MQCHLLIB", "C:\ProgramData\IBM\MQ\qmgrs\QM1\@ipcc");
System.Environment.SetEnvironmentVariable("MQCHLTAB", "AMQCLCHL.TAB");

尝试在启动程序之前设置环境变量,而不是从程序内部设置环境变量。 我在 Windows 和/或 .NET 中发现了在程序中设置环境变量的奇怪问题 - 有时它有效,有时它不起作用。

最后,您是否在运行队列管理器的同一服务器上运行应用程序? 如果是这样,则以"绑定模式"而不是"客户端模式"进行连接。 绑定模式将更快,因为不涉及网络。

最新更新