|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQRC 2142(MQRC_HEADER_ERROR) |
« View previous topic :: View next topic » |
Author |
Message
|
kvranjan10 |
Posted: Wed Aug 18, 2010 2:54 am Post subject: MQRC 2142(MQRC_HEADER_ERROR) |
|
|
Apprentice
Joined: 05 Aug 2008 Posts: 29
|
Hi All,
Let me explain you the problem first.
When we are trying to put message into a queue using a c program abd we are getting this error.
Actually this c program is developed my some other guy in MQ 5.3 version andOS is AIX 32 bit.Now we migrated MQ 5.3 to MQ 7 and OS to AIX 64 bit
Before this error we encountered one more issue that we resovled..The issue is when we try to run the executable of the C program it showed an error saying
Dependent module /usr/mqm/lib64/libmqm.a(libmqm.o) could not be loaded.
The module has an invalid magic number.
Later we changed the libpath in the "makefile" and recomplied with 64 bit libraries.Now that executale is working fine but not able to put the message because of the MQRC 2142 problem.
Our current MQ version is 7.I am attaching the sample code. |
|
Back to top |
|
 |
kvranjan10 |
Posted: Wed Aug 18, 2010 2:55 am Post subject: |
|
|
Apprentice
Joined: 05 Aug 2008 Posts: 29
|
Code: |
int main(int argc, char **argv)
{
MQHCONN hconn;
MQHOBJ hobj;
MQOD mqod;
MQMD mqmd;
MQPMO mqpmo;
MQLONG compCode;
MQLONG reason;
MQRFH2 rfh;
int folderLength;
int newLength;
int payloadLength;
int i;
FILE *f;
char *buffer;
if (argc < 4) {
printf("Usage: %s <queue> <replyq> <qmgr> <payload_file> [<folder1_file> [<folder2_file>...]]\n", argv[0]);
return 1;
}
/* open the queue manager */
MQCONN(argv[3], &hconn, &compCode, &reason);
printf("MQCONN cc=%d rc=%d\n", compCode, reason);
/* open the output queue */
memcpy(&mqod, &mqodModel, sizeof(MQOD));
strncpy(mqod.ObjectName, argv[1], 48);
MQOPEN(hconn, &mqod, MQOO_OUTPUT, &hobj, &compCode, &reason);
printf("MQOPEN cc=%d rc=%d\n", compCode, reason);
/* build RFH2 structure */
memcpy(&rfh, &mqrfhModel, sizeof(MQRFH2));
memcpy(rfh.Format, NEXT_FORMAT, 8);
rfh.NameValueCCSID = 1208; /* UTF-8 */
/* read folders */
folderLength = 0;
for (i = 5; i < argc; i++) {
f = fopen(argv[i], "rb");
if (f == NULL) {
perror(argv[i]);
exit(99);
}
fseek(f, 0, SEEK_END);
newLength = ftell(f);
fclose(f);
newLength = 4 + 4 * ((newLength + 3) / 4);
folderLength += newLength;
}
/* read payload */
f = fopen(argv[4], "r");
if (f == NULL) {
perror(argv[4]);
exit(99);
}
fseek(f, 0, SEEK_END);
payloadLength = ftell(f);
fclose(f);
/* build the message */
buffer = (char *)malloc(sizeof(MQRFH2) + folderLength + payloadLength);
/* move folders into buffer */
if (folderLength > 0) {
folderLength = 0;
for (i = 5; i < argc; i++) {
f = fopen(argv[i], "r");
fseek(f, 0, SEEK_END);
newLength = ftell(f);
fseek(f, 0, SEEK_SET);
newLength = fread(buffer+sizeof(MQRFH2)+folderLength+4, 1, newLength, f);
tidy(buffer + sizeof(MQRFH2)+folderLength+4, &newLength);
*(long *)(buffer + sizeof(MQRFH2) + folderLength) = newLength;
fclose(f);
folderLength += newLength + 4;
}
}
rfh.StrucLength = sizeof(MQRFH2) + folderLength;
memcpy(buffer, &rfh, sizeof(MQRFH2));
/* move payload into buffer */
f = fopen(argv[4], "r");
payloadLength = fread(buffer+sizeof(MQRFH2)+folderLength, 1, payloadLength, f);
fclose(f);
/* put message to output queue */
memcpy(&mqmd, &mqmdModel, sizeof(MQMD));
mqmd.MsgType = MQMT_REQUEST;
strcpy(mqmd.ReplyToQ, argv[2]);
memcpy(&mqpmo, &mqpmoModel, sizeof(MQPMO));
mqmd.Persistence = MQPER_PERSISTENT;
strncpy(mqmd.Format, MQFMT_RF_HEADER_2, MQ_FORMAT_LENGTH);
mqpmo.Options = MQPMO_NO_SYNCPOINT;
MQPUT(hconn, hobj, &mqmd, &mqpmo, sizeof(MQRFH2) + folderLength + payloadLength, buffer, &compCode, &reason);
printf("MQPUT cc=%d rc=%d\n", compCode, reason); |
EDIT by exerk: Please use code tags if you're going to post code, thank you. |
|
Back to top |
|
 |
Mr Butcher |
Posted: Wed Aug 18, 2010 3:39 am Post subject: |
|
|
 Padawan
Joined: 23 May 2005 Posts: 1716
|
Did you look at the 2142 redurncode description and checked all the possible reasons mentioned there? _________________ Regards, Butcher |
|
Back to top |
|
 |
kvranjan10 |
Posted: Wed Aug 18, 2010 3:44 am Post subject: |
|
|
Apprentice
Joined: 05 Aug 2008 Posts: 29
|
Actually i dont have knowledge on MQ coding side...But still i am trying to look the possible ways why this 2142 error will occure. As its very urgent i posted here. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 18, 2010 4:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kvranjan10 wrote: |
Actually i dont have knowledge on MQ coding side.. |
Then how are you going to fix a coding problem?
kvranjan10 wrote: |
But still i am trying to look the possible ways why this 2142 error will occure. |
All the possible ways this error will occur are listed in the reason code description the previous poster mentioned.
kvranjan10 wrote: |
As its very urgent i posted here. |
If it's that urgent you should have raised a PMR with IBM & got the support desk involved. We're just a bunch of volunteers and don't have an SLA on responses.
You need to do more to that code to move it to a 64 bit platform than just recompile it I suspect. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
gbaddeley |
Posted: Wed Aug 18, 2010 3:21 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
Where are all the 'model' structures defined?
Normally a prog like this would just use something like:
Code: |
/* Declare MQI structures needed */
MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */
MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
MQPMO pmo = {MQPMO_DEFAULT}; /* put message options */
|
and not bother with copying them from 'models'. This code is a direct copy from the same amqsput0.c that comes with MQ. _________________ Glenn |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Aug 18, 2010 3:58 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
You switch from 32-bit to 64-bit. Duh!! (AIX 64-bit server does support 32-bit applications!!!)
kvranjan10 wrote: |
Code: |
*(long *)(buffer + sizeof(MQRFH2) + folderLength) = newLength; |
|
How big is a long on a 32-bit platform? How big is a long on a 64-bit platform?
Each RFH2 folder length value is 4 bytes in length. Hence, on a 64-bit platform, you are writing 8 bytes because a long is 64-bits.
Use MQLONG and your problem will go away.
Using long datatypes when porting code between 32-bit and 64-bit platforms is extremely dangerous.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
kvranjan10 |
Posted: Wed Aug 18, 2010 7:53 pm Post subject: |
|
|
Apprentice
Joined: 05 Aug 2008 Posts: 29
|
heartfull Thanks to all for the replies.
Jedi, i will try changing the LONG to MQLONG and let you the know the result. |
|
Back to top |
|
 |
kvranjan10 |
Posted: Wed Aug 18, 2010 8:33 pm Post subject: |
|
|
Apprentice
Joined: 05 Aug 2008 Posts: 29
|
Hi Jedi,
Thank you Soooo Much..Now its working fine...
Once again Thank you very much to all for helping me.... |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|