|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQ MgId problem |
« View previous topic :: View next topic » |
Author |
Message
|
vsk |
Posted: Fri May 23, 2003 11:57 am Post subject: MQ MgId problem |
|
|
Novice
Joined: 25 Apr 2003 Posts: 24
|
Hi,
I am settgin the MsgId to a value before putting the message to the Message Queue. But Somehow when I am looking at the MQ header of the Message on the Queue I see that the MsgId is not the one set by me and it's showing some MQ generated Message Id.
Can anyone tell me what extra needs oto be done to set the message id
here is the code.
MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
MQPMO pmo = {MQPMO_DEFAULT}; /* put message options */
MQLONG CompCode; /* completion code */
MQLONG Reason; /* reason code */
pmo.Options = pmo.Options + MQPMO_SET_IDENTITY_CONTEXT;
/* memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));*/ /* reset MsgId to get a new one */
strcpy(md.MsgId, msg_id);
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId)); /* reset CorrelId to get a new one */
memcpy(md.Format, MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH); /* character string format */
if(strlen(userid_passwd) != 0)
strncpy(md.ApplIdentityData,userid_passwd,strlen(userid_passwd));
if(strlen(replyQ) != 0)
strncpy(md.ReplyToQ, replyQ, MQ_Q_NAME_LENGTH); /* character string format */
if(strlen(replyQMgr) != 0)
strncpy(md.ReplyToQMgr, replyQMgr, MQ_Q_MGR_NAME_LENGTH); /* character string format */
if (syncPoint==1)
pmo.Options = pmo.Options + MQGMO_SYNCPOINT;
MQPUT(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&pmo, /* default options (datagram) */
buflen, /* buffer length */
buffer, /* message buffer */
&CompCode, /* completion code */
&Reason); /* reason code */ |
|
Back to top |
|
 |
tallison |
Posted: Fri May 30, 2003 7:25 am Post subject: |
|
|
 Apprentice
Joined: 18 Jun 2002 Posts: 39 Location: Round Rock, Texas
|
Good morning,
Your statement in the code (MQMI_NONE) and (MQCI_NONE) is telling the queue manager to generate a message ID These clear the fields in the MQMD and the queue manager populates the field with a new value. If you want to specify a message ID you would move that value to the field instead of MQMI_NONE.
This is what I believe to be the case.
Have a good day
Sincerely,
Tony Allison _________________ Cheers!!
Tony Allison
_________________
MQSeries Certified Specialist
MQSeries Certified Developer
MQSeries Certified Solutions Provider |
|
Back to top |
|
 |
vsk |
Posted: Mon Jun 02, 2003 4:28 am Post subject: |
|
|
Novice
Joined: 25 Apr 2003 Posts: 24
|
Thank you very much Tony for the response.
I tried to do as you said but still I am not able to set the message id.
Do you know if I need to set anything else for this.
Thanks,
VSK |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 02, 2003 5:20 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You have the following in your code, right after the commented out code that told MQSeries to generate a new Message ID:
Quote: |
strcpy(md.MsgId, msg_id); |
So you are putting the contents of msg_id into md.MsgId. But you don't have in the code shown anything that puts a value into msg_id. Are you leaving it blank? |
|
Back to top |
|
 |
vsk |
Posted: Mon Jun 02, 2003 6:08 am Post subject: |
|
|
Novice
Joined: 25 Apr 2003 Posts: 24
|
No I am passing the msgid to the mqPut wrapper function written by me
as shown below
MQLONG mqPut(Hcon, Hobj, syncPoint, buffer, buflen, msg_id, replyQ, replyQMgr, u
serid_passwd)
MQHCONN Hcon; /* connection handle */
MQHOBJ Hobj; /* object handle */
int syncPoint; /* syncpoint flag. Perform syncpoint or not */
char *buffer; /* message buffer */
MQLONG buflen; /* buffer length */
char msg_id[9+1];
char replyQ[128];
char replyQMgr[128];
char userid_passwd[17];
And in this function I am doing "strcpy(md.MsgId, msg_id); "
Thanks,
VSK
Thanks,
Vinayak |
|
Back to top |
|
 |
RogerLacroix |
Posted: Mon Jun 02, 2003 9:30 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
What is with the char msg_id[9+1]; ?
The size of a MQMD.MsgId is 24 bytes (and not 24+1).
This is the problem with wrappers that do simple gets & puts.
Also, MsgId, CorrelId & GroupId are byte fields. That means you should NOT be using 'C' string functions to work with these fields. You should be using memcpy. i.e.
Code: |
MQBYTE24 msg_id;
memcpy( md.MsgId, msg_id, sizeof(md.MsgId));
or
memcpy( md.MsgId, MQMI_NONE, sizeof(md.MsgId));
memcpy( md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));
memcpy( md.GroupId, MQGI_NONE, sizeof(md.GroupId)); |
Hope that helps.
later
Roger... _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
vsk |
Posted: Mon Jun 02, 2003 10:35 am Post subject: |
|
|
Novice
Joined: 25 Apr 2003 Posts: 24
|
I changed msg_id to MQBYTE24
See I have ext_msg_id field which is a char(10) and has number stored in it.
I do the following
char ext_msg_id(10);
int msg_id ;
msg_id = atoi(ext_msg_id)
mqPut iis a wrapper funtion
I pass the variables to this function as follows
mqPut( st_glob.Hcon, /* connection handle */
st_glob.H_lnt_cntrct_add_Qobj, /* object handle */
1, /* Use SynPoint controls */
(char *) &comm_rec, /* message buffer */
(MQLONG) send_length, /* send data length */
(MQBYTE24) msgid,
st_glob.c_replyQ,
st_glob.c_replyQMgr,
userid_passwd);
Now when I compile my c program I am getting the following error
"cast specifies array type"
Please help
Thanks
VSK |
|
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
|
|
|
|