IBM MQ Server Setup to Create CCDT file used by .N

2019-08-28 05:08发布

问题:

I need to use CCDT file for MQ.NET client to connect to MQ Server, both are running locally, but got error below.

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

Please find below the server setup, and MQ.NET client.

Server Setup

I setup and created CCDT file following the links below:

Setting up the server using IBM MQ Explorer

Server-connection Channel: LOCAL.DEF.SVRCONN

MCA User ID: I tried either omitting it or providing it. And either member of mqm or not of it.

Setting up the client using IBM MQ Explorer

Clinet channe: LOCAL.DEF.SVRCONN

Queue Manager name: LocalQM

Connection name: 192.168.1.9 (1415)

192.168.1.9 is localhost address

1415 is queue manager, LocalQM, TCP port.

IBM MQ.NET

The code is below from 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 on Windows 10

MQ.NET Client V8 on Windows 10

Creating a client channel definition table

Using a client channel definition table with .NET

UPDATE

If I change to below without using CCDT, it works.

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

UPDATE 2 I changed queue manager to 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>

UPDATE 3: MQRC_NOT_AUTHORIZED is Not resolved

I changed

  1. 192.168.1.9 (1415) -> 192.168.1.9(1415)
  2. Put AMQCLCHL.TAB also to C:\ProgramData\IBM\MQ (I don't know why which might not be correct, because error on log file:

    AMQ9518: File 'C:\ProgramData\IBM\MQ\AMQCLCHL.TAB' not found.

)

3 I tried MCA User Id ->

1 mqlclient who is memeber of mqm

2 mqlclient who is not memeber of mqm

3 empty

But still got error. Below is exception and error for 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 -------------------------------------------------------

回答1:

OP added the following information to the question in UPDATE 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

I see two possible issues with the CCDT:

  1. You have a space in the CONNAME between the IP and the open parenthesis. This may be causing MQ to disregard the port 1415 and use the default port 1414, it also may ignore the space and it may not be a problem, I have never tested with a space.

    COMPMSG(NONE)                           CONNAME(192.168.1.9 (1415))
    
  2. The QMNAME of the CLNTCONN channel should match what you are specifying in the call to new MQQueueManager, so this should say QM1 not LocalQM, this is likely the direct reason for your 2058 error, but #1 may cause an issue as well once you fix #2.

    QMNAME(LocalQM)                         RCVDATA( )
    

There are also other uses for QMNAME where you can specify a group name or a blank. See my answer to "Connecting to IBM MQ using CCDT file in JMS " for more details on this. The answer is related to JMS but the information presented for the setQueueManager would be the same as the first parameter to your call to new MQQueueManager.



回答2:

Generally speaking, reason code of 2058 (MQRC_Q_MGR_NAME_ERROR) means that you have an invalid queue manager name or that the server does not have that particular queue manager. Check the spelling of the queue manager name that you inputted. Also, queue manager names are case sensitive (e.g. MQA1 is not the same as mqa1).

Also, every queue manager will have its own port #. i.e. 1414, 1415, 1416, etc. So, if there is more than 1 queue manager running on that server then make sure you are using the correct port.

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

Try setting the environment variables before starting your program rather than from inside your program. I have found weird issues in Windows and/or .NET with setting environment variables inside a program - sometimes it works, sometimes it doesn't.

Finally, are you running your application on the same server as where the queue manager is running? If so, then connect in 'bindings mode' rather than 'client mode'. Bindings mode will be way faster as there is no network involved.



标签: c# ibm-mq