Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to run the sample c++ application on MQSeries for Windows NT

Status
Not open for further replies.

esomu

Programmer
Aug 23, 2000
1
US
Hi,
Trying to run the imqwrlds (The hello world program) -- a sample program in C++. Getting the following error message.

ImqQueueManager: connect failed with reason code 2059.

Please help.

Thanks
Soma

PS: The queue manager is running. Verified with a sample application using the JMS interface.
 
If you specified the QMgr as a parameter on the command line, are you sure you used the right case - MQ objects are case-sensitive.

If you didn't specify it, have you defined a queue manager as being the default?
 
I am getting a similar problem with the same program. I have used the right case and it is the default queue manager on my comp.
 
Ok - in that case, are you using the client connection method or the direct connection? If the client, are you specifying the same port that the MQ listener is listening on - and is the listener actually running?

If you are connecting directly, are you running your program in a Windows Terminal Services session? If so it won't work - you need to specify the client connection.

Cheers,
Paul
 
Hi Paul,

I am sending a portion of the program. It fails at the point i try to connect. I am runnig it from Visual Studio6.

Sanjay

int main ( int argc, char * * argv ) {
ImqQueueManager mgr;
ImqQueue queue; ImqMessage msg;
ImqGetMessageOptions gmo;
char buffer[ 101 ];

printf( "Sample IMQSGET start\n" );
if ( argc < 2 ) {
printf( &quot;Required parameter missing - queue name\n&quot; );
exit( 99 );
}

queue.setName( argv[1]);
mgr.setName( argv[ 2 ] )

/* Connect to queue manager */

if ( ! mgr.connect( ) ) {
/* stop if it failed */
printf( &quot;ImqQueueManager::connect failed with reason code %ld\n&quot;,
(long)mgr.reasonCode( ) );
exit( (int)mgr.reasonCode( ) );
}
 
I am having a similar problem to the kind sanvaranas is having. I have MQSeries installed on my system. I have created a default Q manager called QMGR1. At the time of creation of queue manager i checked the option to create a listener for TCP/IP to work on port 1414. I have a sender channel to send message to another queue manager QMGR2 on another machine and a receiver channel to receive. I have the necessary remote and local queues defined.

From the other machine on which QMGR2 is running i put a message to QMGR1 using a simulator. The message comes to my machine and is there in my queue. Now using the sample program imqsget.cpp available in sample directory of mqsereies/cplus i try to read it. I have compiled this program in Visual Studio and am running it from there. My queue manager is also on the same machine. I specify the qmanager name as QMGR1 and the name of the queue on which the message has come. But i get a 2058 error.

What i dont understand is even if i do not give a queue manager name in MQCONN(QMName,&Hcon,&CompCode,&CReason) how can a program connect to the default queue manager. In any case even after specifying the q manager name i am not able to connect.

I suppose this kind of connection would be called direct connection as the program is on the same machine on which the q manager is installed. I am not trying to connect from another machine to read from it. This is a requirement not an option for me.
 
Another thing i forgot to mention. When i run the exe imqsgets.exe provided by IBM in \cplus\samples\in directory the program is able to read the message from the queue that i specify. But when i use imqsgetc.exe provided in the same directory it throws a connect failed reason code 2059 error
 
Ok - I have never really bothered much with the C++ API of MQ but they all seem to do the same thing.

rups123 - the reason that imqsgets.exe works but imsgetc.exe doesn't is (probably) because the first one uses the direct MQ connection whereas the second uses the client connection.

The direct interface uses IPC to allow a process running on the same machine as the QMgr to connect to it. The client interface uses sockets for this connection and can be used both by processes running on the same machine as well as on different ones. In both cases however they need to connect via the TCP port that your listener is listening on. Whether a program uses the client or direct is (usually) determined by which MQ library you include at link time - check the Application Programming Guide for your specific platform to find the names of the libraries but for Windows mqm.lib is direct and mqic32.lib is for clients.

To check this, set environment variable MQSERVER=SYSTEM.DEF.SVRCONN/TCP/127.0.0.1(1414) and try to run the imsgetc.exe again.

savaranas - you can try the same thing too to check if you've linked your program with the MQ client library.

Cheers,
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top