Author |
Message
|
vignesh1988 |
Posted: Sat Apr 13, 2013 3:01 am Post subject: My C program Ended with MQRC 2059 |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
I wrotw a C Program which connects and Disconnects from a Queue Manager on Linux Platform. The qmgr name is hard coded on the code itself,
Here is my Code:
Code: |
#include<stdio.h>
#include<stdlib.h>
/* Used for MQ API calls*/
#include<cmqc.h>
int main()
{
MQHCONN Hcon2; /* connection handle */
MQLONG CompCode; /* completion code */
MQLONG Reason; /* reason code */
MQLONG CReason; /* reason code for MQCONN */
char qmgr[5]="LQUA"; /* Queue Manager Name for connection in an Array */
/*************************************/
/* MQ Connection for a Queue Manager */
/* This Functions helps to connect */
/* to a Queue manager specified on */
/* "qmgr" array. */
/* Return Values: Hcon,CompCode */
/* & CReason */
/*************************************/
MQCONN (qmgr,&Hcon2,&CompCode,&CReason);
/*************************************/
/* Validation is done if the */
/* Connection is successfull. */
/* MQCC_FAILED = 2 as per cmqc.h */
/*************************************/
if (CompCode == MQCC_FAILED)
{
printf("can't connect: %d %d\n",CReason,CompCode);
exit(CReason);
}
else
{
printf(" MQRC CC\n");
printf("Connected to the Qmgr %s : %ld %ld\n",qmgr,CReason,CompCode);
/**********************************/
/* MQ DIsconnect from a Queue */
/* Manager */
/**********************************/
MQDISC (&Hcon2,&CompCode,&Reason);
/**********************************/
/* Checks if the Reason != 0 */
/* If !0 , then Prints the Reason */
/**********************************/
if (Reason != MQRC_NONE)
{
printf("Ended with reason : %d\n",Reason);
}
else
{
printf(" MQRC CC\n");
printf("Disconnected from the queue manager %s : %ld %d\n",qmgr,Reason,CompCode);
}
}
return (0);
} |
When i run this code particurlarly connecting to this qmgr i get 2059 error, This C is compiled in "gcc". The same code when run in another Linux platform works well..
1) The Queue Manager is running
2) When i execute some sample program in /opt/mqm/samp like amqsput that is working fine..
I really do not understand what's the error i have made (or) some configuration issue.. The puzzling thing is -> The same code works fine on other qmgrs..... Can anybody assist me .. it's a Bit Urgent thing...
Version is : -bash-3.2$ dspmqver
Name: WebSphere MQ
Version: 7.0.1.9
CMVC level: p701-109-120718
BuildType: IKAP - (Production) |
|
Back to top |
|
 |
exerk |
Posted: Sat Apr 13, 2013 6:57 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Queue manager names are case sensitive - are you sure your queue manager name is LQUA? And if you are getting the issue because of a difference in case, it's a wonderful demonstration of why you should not hard code WMQ object names...
Also, please use the code tags when posting your code as it makes it easier to read and see where narrative and and code blocks begin and end. _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
bruce2359 |
Posted: Sat Apr 13, 2013 8:26 am Post subject: Re: My C program Ended with MQRC 2059 |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9470 Location: US: west coast, almost. Otherwise, enroute.
|
vignesh1988 wrote: |
When i run this code particurlarly connecting to this qmgr i get 2059 error |
Does this code successfully connect to other qmgrs in this same o/s image? Or, is this the only qmgr in this o/s image? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Sat Apr 13, 2013 11:29 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
exerk wrote: |
Queue manager names are case sensitive - are you sure your queue manager name is LQUA? And if you are getting the issue because of a difference in case, it's a wonderful demonstration of why you should not hard code WMQ object names...
|
But that would throw a 2058 and not a 2059 error.... _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
exerk |
Posted: Sat Apr 13, 2013 12:01 pm Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
PeterPotkay wrote: |
exerk wrote: |
Queue manager names are case sensitive - are you sure your queue manager name is LQUA? And if you are getting the issue because of a difference in case, it's a wonderful demonstration of why you should not hard code WMQ object names...
|
But that would throw a 2058 and not a 2059 error.... |
Another one of my stellar posts  _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
Vitor |
Posted: Sat Apr 13, 2013 2:21 pm Post subject: Re: My C program Ended with MQRC 2059 |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vignesh1988 wrote: |
When i execute some sample program in /opt/mqm/samp like amqsput that is working fine.. |
The amqsput sample is probably doing something different to your application; a 2059 error is typically a client error. Try running amqsputc and see if that works.
Also are you running the sample program from the same server as you're running your application? Using the same configuration?
vignesh1988 wrote: |
I really do not understand what's the error i have made (or) some configuration issue.. |
What configuration have you performed? You've not mentioned any here. You've not even mention if you think your code is server side (making amqsput the correct sample to try) or a client side one (making amqsputc the correct choice) and if so, what you've done to supply the client details to your application.
vignesh1988 wrote: |
The puzzling thing is -> The same code works fine on other qmgrs..... |
Well other servers are configured in other ways. If you have a server side application and the other queue managers have you running this code of yours in the same space they'll work. If your application is a client and the other queue managers have default client configurations which your code can access then they'll work. Not puzzling at all. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mvic |
Posted: Sat Apr 13, 2013 4:52 pm Post subject: Re: My C program Ended with MQRC 2059 |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
vignesh1988 wrote: |
char qmgr[5]="LQUA"; /* Queue MQCONN (qmgr,&Hcon2,&CompCode,&CReason); |
You're passing a 5-byte data area in the first argument of the MQCONN call. Try passing a 48-byte area as specified. It probably won't make a difference but is worth trying. |
|
Back to top |
|
 |
vignesh1988 |
Posted: Sun Apr 14, 2013 6:58 pm Post subject: Re: My C program Ended with MQRC 2059 |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
Nope, I run my code on the Server itself (Where QM is present), No Client connections.
I meant "Configuration" is Compiler configuration (Might be having some Bug).
Let me tell you what are the possible tries i made to understand what's is happening:
TRY-1: I first copied the amqsput0.c from /opt/mqm/samp to my HOME directory and executed via "GCC" compiler
RESULT-1: Compiled successfully , Ran the executable - Failed with 2059.
But the Executable provided on /opt/mqm/samp/bin "ran" successfully.
INFERENCE: I thought "gcc" compiler might not be installed properly on that server.
TRY-2: Then i complied the same code on another server and made a "Executable" and executed once , it was connecting successfull.
RESULT-1: I "scp"ied the same executable to the "Non-Working" server and executed there , It failed with "2059" again.
INFERENCE: I had 50% belief that Complier has no issues. All Configurations are proper.
How come the same code is working on other servers and not in this server.. i really do not understand. Please help me. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Apr 14, 2013 9:02 pm Post subject: Re: My C program Ended with MQRC 2059 |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
vignesh1988 wrote: |
Nope, I run my code on the Server itself (Where QM is present), No Client connections.
I meant "Configuration" is Compiler configuration (Might be having some Bug).
Let me tell you what are the possible tries i made to understand what's is happening:
TRY-1: I first copied the amqsput0.c from /opt/mqm/samp to my HOME directory and executed via "GCC" compiler
RESULT-1: Compiled successfully , Ran the executable - Failed with 2059.
But the Executable provided on /opt/mqm/samp/bin "ran" successfully.
INFERENCE: I thought "gcc" compiler might not be installed properly on that server.
TRY-2: Then i complied the same code on another server and made a "Executable" and executed once , it was connecting successfull.
RESULT-1: I "scp"ied the same executable to the "Non-Working" server and executed there , It failed with "2059" again.
INFERENCE: I had 50% belief that Complier has no issues. All Configurations are proper.
How come the same code is working on other servers and not in this server.. i really do not understand. Please help me. |
What is the value of the environment variables from memory so look up the correct name:
MQServer, MQCHLLIB, MQCHLTAB, MQSSLKEYR
Is there a difference in version between the MQ servers. Like the non working one is at V 7.1.x or V 7.5.x ?
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
vignesh1988 |
Posted: Mon Apr 15, 2013 12:00 am Post subject: Re: My C program Ended with MQRC 2059 |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
No the version of MQ is 7.0..
There is no env variables needed i think , because no client involved here.. i trying the code in the server itself. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 15, 2013 4:42 am Post subject: Re: My C program Ended with MQRC 2059 |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vignesh1988 wrote: |
There is no env variables needed i think , because no client involved here.. i trying the code in the server itself. |
You think wrong. If the code is running on the server itself but the code is attempting to establish a client connection (in the WMQ sense of the word "client") then you do need those environment variables and will get a 2059 if they're not present. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
gbaddeley |
Posted: Mon Apr 15, 2013 6:22 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
What command did you use to compile / link the program? (would like to know the MQI library that you are linking to) _________________ Glenn |
|
Back to top |
|
 |
vignesh1988 |
Posted: Mon Apr 15, 2013 10:58 pm Post subject: |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
gcc -m64 <Outfile> <InFile.c> -I/opt/mqm/inc -L/opt/mqm/lib64 -Wl,-rpath=/opt/mqm/lib64 -Wl,-rpath=/usr/lib64 -lmqm
The above command i found in WMQ Application Guide in "How to prepare MQ C program in Linux"
-m64 -> it's a 64 bit
/opt/mqm/inc -> Where my MQ Headers present
/opt/mqm/lib64 -> Library Path
-bash-3.2$ uname -a
Linux r16cn00 2.6.18-238.5.1.el5 #1 SMP Mon Feb 21 05:52:39 EST 2011 x86_64 x86_64 x86_64 GNU/Linux |
|
Back to top |
|
 |
vignesh1988 |
Posted: Mon Apr 15, 2013 11:14 pm Post subject: |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
Just now gave a "Try" to compile with the argument -m32 instead of -m64, It worked
Same i scp'ed to 2 other severs and tried , that also working..
Wat i could infer from this is : In the NON working server they have installed 32 Bit Compiler , But i done for 64 Bit..
Please correct me if am wrong..
Also thanks everyone, Thanks personally for the last "Replier" who opened an another way to me to think for execting as a 32 bit ones...
Thanks all...
I am gonna try everywhere and check |
|
Back to top |
|
 |
gbaddeley |
Posted: Tue Apr 16, 2013 3:23 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
-lmqm
You are linking to the MQ server binding library. For the MQCONN to work, the program *must* be running on the same OS image as the Queue Manager.
ie. you are not using MQ client. _________________ Glenn |
|
Back to top |
|
 |
|