Author |
Message
|
lifeng |
Posted: Fri Jan 11, 2008 8:46 am Post subject: MQCONN failed in C program converted from UNIX to Windows |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Hi there,
We have been running a UNIX/C based system that communicates with MQSeries through API. That system works fine under UNIX. Now I am assigned the task of porting the system over to Windows. What I have done so far is:
1) I have installed MQSeries (v5.3) on my local machine.
2) Created a local queue manager named QM_QICLINK, which is the same name we use under UNIX.
3) Created a couple of local queues under QM_QICLINK.
4) Brought the C program over and compiled under Windows on the same machine MQSeries installed on.
5) Ran the program and try to call MQCONN with the following code:
char QMName[50]="";
QMName[0]='\0';
strcpy(QMName,"QM_QICLINK");
QMName[10]='\0';
MQHCONN Hcon;
MQLONG CompCode;
MQLONG CReason;
MQCONN(QMName, &Hcon, &CompCode, &CReason);
Then the call came back failed with a return code CompCode = 2 and CReason = 2058.
I am new to MQSeries and its APIs but as far as I can see, I am trying to keep everything the same as under UNIX. What am I missing here? If someone could shed some light it will be highly appreciated.
Thanks in advance!
Lifeng |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 11, 2008 9:00 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
try using amqscnx to connect to the qmgr.
Make sure that the queue manager is started.
If you're moving the program from unix to Windows, you should be moving it to use a supported (v6) version of MQ, instead of keeping the same unsupported v5.3. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
lifeng |
Posted: Fri Jan 11, 2008 9:24 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Hi jefflowrey,
Thanks for your response!
You have to excuse me for my ignorance on MQSeries. Like I said, I am really new in this field. Could you elaborate a little bit more on "using amqscnx to connect to the qmgr"? Is AMQSCNX the Windows equivalent of MQCONN of UNIX? Is this only available for V6? Where can I find API doc for it? All the API doc, including the Windows sample code come with the MQSeries for Windows installation, seems suggesting that MQCONN should work in my case, but how come I couldn't make it happen?
Once again, thank you so much for your valuable inputs!!!
Lifeng |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Jan 11, 2008 9:31 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
lifeng wrote: |
Could you elaborate a little bit more on "using amqscnx to connect to the qmgr"? Is AMQSCNX the Windows equivalent of MQCONN of UNIX? Is this only available for V6? Where can I find API doc for it? |
Its a sample program shipped with all MQ Client installs. Its as simple as it gets, it just connects to the QM and then disconnects. We use it to prove that your MQ Client machine can get to the QM. If not, don't worry about your app yet, get the connectivity via amqscnxc going first. Once that works you know your app should be able to as well.
Source code is provided as well for amqscnxc. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
bower5932 |
Posted: Fri Jan 11, 2008 9:32 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
If you are just starting out, then you should move to v6 since v5.3 is long out of support. |
|
Back to top |
|
 |
lifeng |
Posted: Fri Jan 11, 2008 11:18 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
I ran amqscnxc and this is what I got:
C:\Program Files\IBM\WebSphere MQ\Tools\c\Samples>amqscnxc QM_QICLINK
Sample AMQSCNXC start
Connecting to queue manager QM_QICLINK
with no client connection information specified.
MQCONNX ended with reason code 2058
I also tried call amqscnxc without argument but that didn't make any difference. I got the same error for connecting to DEFAULT queue manager.
Can someone tell me what is wrong here? What is the "client connetion information"? How do I specify it?
Thanks!
Lifeng |
|
Back to top |
|
 |
bower5932 |
Posted: Fri Jan 11, 2008 11:33 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
Check out the prologue of the program. You need to specify various parameters based on what you are trying to do. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 11, 2008 11:50 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Isn't there a bindings version of amqscnxc? I guess not. Dang memory - at least it brought back the coffee..
Try amqsput. It's simpler, and will connect to the local qmgr using a bindings connection, which your code is also trying to do. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Jan 11, 2008 12:04 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
lifeng,
what does the output of the command dspmq show? _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
lifeng |
Posted: Fri Jan 11, 2008 1:16 pm Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
1) Output of dspmq is:
C:\Program Files\IBM\WebSphere MQ\Tools\c\Samples\Bin>dspmq
QMNAME(QM_QICLINK) STATUS(Running)
QMNAME(QM_THG) STATUS(Running)
2) Output of amqsput is:
C:\Program Files\IBM\WebSphere MQ\Tools\c\Samples\Bin>amqsput BS_QICLINK_270
Sample AMQSPUT0 start
MQCONN ended with reason code 2059
Here the BS_QICLINK_270 is a queue defined under QM_QICLINK
3) I tried running MQCONN in API Exerciser against queue manager QM_QICLINK and it works fine (return status OK). I can even do a MQPUT and MQGET against BS_QICLINK_270 with API Exerciser and QM_QICLINK.
Any ideas?
Thanks you guys so much!!!
Lifeng |
|
Back to top |
|
 |
lifeng |
Posted: Fri Jan 11, 2008 2:06 pm Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
I just found that I made a mistake in running amqsput command by missing an argument - queue manager name. When I corrected this and run it, it works. After running this command, I can see the message I put in the queue from the MQ Explorer.
When I tried to run my own code to call MQCONN, however, it still failling - I still get the 2058 reason code back.
Does that mean that my local queue manager is OK but my program is bad? But as far as I can see, I am doing the same thing the amqsput0.c source code is doing. I don't know if it has anything to do with the issue, but maybe I should mention this as well, my application is a .Net application. The C code is now running under .Net as well but it is running as un-managed code.
Thanks again.
Lifeng |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jan 14, 2008 1:54 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lifeng wrote: |
Does that mean that my local queue manager is OK but my program is bad? |
I'm afraid it does.
The code may be doing the same thing as the sample, but what it's not doing is correctly suppling your queue manager name to the MQCONN call. The 2058 (as you've undoubtedly discovered from your own reaearches) means the queue manager you're trying to connect to can't be found.
Double check the code setting the queue manager name. Especially if you're still using the code fragment in your first post!  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jan 14, 2008 3:32 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
And remember here names are case sensitive. If the case doesn't match the connection will fail.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
lifeng |
Posted: Mon Jan 14, 2008 7:14 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Thank you again for all of your inputs & advises.
Based on my research over the weekend I am now more convinced that my problem has something to do with the fact that my program calling MQCONN is a .Net program (unmanaged C++ .Net program), not a Windows based C program, like those samples are.
Now, let me ask you the following:
1) is there a recommended approach from MQSeries that a unmanaged .Net program should follow in communicating with MQ using API? Since my program is converted from a native C program and it it big and very complex, I prefer not to convert it into managed .Net code if possible.
2) if I must convert my code into managed, then what is standard approach for a .Net program to invoke a native MQSeries API function, such as MQCONN, without installing any additional MQ components?
3) what my other options are?
Thanks again for all of your help!!!
Lifeng |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jan 14, 2008 7:36 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
|