1
votes

I need to write a piece of code to put a message into MQ using C++. When I test it on localhost, using the default port (1414) it works. However, in the actual environment, which uses specific channel definition and different port (1420), it fails with reason code 2058 / MQRC_Q_MGR_NAME_ERROR. There is no problem connecting to the remote MQ using Websphere MQ Explorer. There is also no problem connecting to the same remote server in a C# app to prove connectivity. Any ideas what could be causing it?

Some sample code extract: C++ which fails when .connect() is called...

ImqChannel * pChannel_ = 0;  // Channel definition which is at class level
ImqQueueManager queueManager_;   // Queue Manager, also declared at class level


// extract from the MQHelper::Connect() method... 
int MQClient::Connect() {
   pChannel_ = new ImqChannel;
   pChannel_->setChannelName("CLCHL.QM");
   pChannel_->setTransportType(MQXPT_TCP);
   pChannel_->setConnectionName("10.2.3.4(1420)");
   // Should we set this???! pChannel_->setModeName("to what?");

   queueManager_.setName("QM");
   queueManager_.setChannelReference(pChannel_);

   if (!queueManager_.connect()) {
      // ERROR IS HERE: _lastCompletionCode is 2, _lastReasonCode is 2058
      _lastCompletionCode = queueManager_.completionCode();
      _lastReasonCode = queueManager_.reasonCode();
      return (int)_lastReasonCode;
   }
    // If we get here, we're all good:
   return 0;
}

In C#, there is no such problem: the following code will connect fine..

queueManager = new MQQueueManager("QM", "CLCHL.QM", "10.2.3.4(1420)");

Other info:

  • Server MQ installation is 7.0.1.0 Websphere MQ Explorer version:
  • 7.5.0.1 (no problem connecting here) In the C# app, I am only referencing amqmdnet.dll... all fine.
  • In the C++ app, I have the external dependencies set up for the 26 various mq .h or .hpp files.
  • Also I have included the appropriate libs etc... again - I know it is capable of working as it the same code will work pointing to a localhost queue manager.
  • I am using VS 2017

Any ideas?

1
QM name is not a mandatory field. You can try removing the QM name and see if it works or notsubbaraoc
Hi, I commented out the .setName("QM") statement. That resulted in a reason code of 2059 / MQRC_Q_MGR_NAME_ERROR. So no joy there.collumbo
The only difference between the c# application and the c++ application could be "setTransportType(MQXPT_TCP);"subbaraoc
"setTransportType(MQXPT_TCP);" - that is correct - see comments below about compiling/linking of the program.Roger

1 Answers

1
votes
ImqChannel * pChannel_ = 0;  // Channel definition which is at class level
ImqQueueManager queueManager_;   // Queue Manager, also declared at class level

What's with the extra underscore in the variable names?

queueManager_.setName("QM");

Is that the ACTUAL queue manager name of the remote queue manager? It needs to be the correct value. Note: MQ is case sensitive. ie. "QM" is not the same as "qm".

Each queue manager's listener listens on a different port.

pChannel_->setConnectionName("10.2.3.4(1420)");

Are you sure queue manager "QM" is actually listening on port 1420 and not 1414 or 1419 or 1421 etc..