IBM MQ 服务器设置以创建 .NET 客户端使用的 CCDT 文件

IBM MQ Server Setup to Create CCDT file used by .NET Client

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

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

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

服务器设置

我通过以下链接设置并创建了 CCDT 文件:

Setting up the server using IBM MQ Explorer

服务器连接通道:LOCAL.DEF.SVRCONN

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

Setting up the client using IBM MQ Explorer

客户频道:LOCAL.DEF.SVRCONN

队列管理器名称:LocalQM

连接名称:192.168.1.9 (1415)

192.168.1.9 是本地主机地址

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

IBM MQ.NET

下面的代码来自here

        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);
        }

IBM MQ V8 在 Windows10

MQ.NET Windows 10

上的客户端 V8

Creating a client channel definition table

Using a client channel definition table with .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 我将队列管理器更改为 LocalQM

C:\Users\'#.lp\source>SET MQCHLLIB=C:\ProgramData\IBM\MQ\qmgrs\LocalQM\@ipcc

C:\Users\'#.lp\source>SET MQCHLTAB=AMQCLCHL.TAB

C:\Users\'#.lp\source>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\'#.lp\source>

更新 3:MQRC_NOT_AUTHORIZED 未解决

我改了

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

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

)

3 我试过了 MCA 用户 ID ->

1 个 mqlclient,他是 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 'bin\Debug\Producer.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 -------------------------------------------------------

一般来说,原因代码 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 and/or .NET 中发现了奇怪的问题,在程序中设置环境变量 - 有时有效,有时无效。

最后,您 运行 您的应用程序是否与队列管理器 运行 在同一台服务器上?如果是,则连接 'bindings mode' 而不是 'client mode'。由于不涉及网络,绑定模式会更快。

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

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

我发现 CCDT 有两个可能的问题:

  1. 您在 IP 和左括号之间的 CONNAME 中有一个 space。这可能导致 MQ 忽略端口 1415 并使用默认端口 1414,它也可能忽略 space 并且这可能不是问题,我从未用 space.[=24 测试过=]

    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 的第一个参数相同。