Author |
Message
|
nascar8mdj |
Posted: Thu Feb 08, 2007 9:44 am Post subject: Get Message - skipping Message Header |
|
|
Newbie
Joined: 08 Feb 2007 Posts: 6
|
Is there a way to only retrieve the Message portion of the data without getting the Message Header? In my scenario, this particular Queue will only be used for one reason so all I really need to get is the Message. If not, is there a guarantee that the Message Header will always be the same length? |
|
Back to top |
|
 |
zpat |
Posted: Thu Feb 08, 2007 10:51 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
What language are using calling the MQI in? |
|
Back to top |
|
 |
EddieA |
Posted: Thu Feb 08, 2007 10:54 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
What message header. The MQMD and message payload are presented in different parameters/structures.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
nascar8mdj |
Posted: Thu Feb 08, 2007 1:01 pm Post subject: |
|
|
Newbie
Joined: 08 Feb 2007 Posts: 6
|
zpat wrote: |
What language are using calling the MQI in? |
COBOL |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 08, 2007 1:22 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
nascar8mdj |
Posted: Thu Feb 08, 2007 1:30 pm Post subject: |
|
|
Newbie
Joined: 08 Feb 2007 Posts: 6
|
jefflowrey wrote: |
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzak.doc/csqzak10309.htm
None of these parameters are optional.
You can safely ignore whatever is populated in them, depending on your functional requirements. |
I have all these parameters defined when doing the GET. What I get back in the BUFFER is what I call the Message Header (Message Descriptor?) AND the Message Data. All I want in this area is the Message Data. I have 2 different Queues that I read from for 2 different processes and it appears that the Message Header is a different length for each process.
This is my first MQ experience so maybe I just don't understand what I'm getting back and how to handle it. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 08, 2007 1:44 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Okay.
What you'll get back in the Message Descriptor is the MQMD header.
The format field on that MQMD header will indicate if there are *additional* headers in the message. IF there are additional headers in the message, then they will be in the Message Body.
So that's probably what you're seeing - additional headers.
If you are getting messages from a Java program that is using JMS - the simplest solution is to ask them to set the TargetClient on their configuration to MQ, rather than JMS.
If you're not getting messages from a JMS application, then you'll have to look at the MQMD Format field and determine what kind of header it is. That will help you determine what you can do to skip or ignore it.
Or you can try and code COBOL to skip everything in the Message Body until you reach a blank line/record. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
nascar8mdj |
Posted: Thu Feb 08, 2007 2:04 pm Post subject: |
|
|
Newbie
Joined: 08 Feb 2007 Posts: 6
|
Thanks! That information helps alot. You are correct, I am receiving data from a JAVA application. |
|
Back to top |
|
 |
nascar8mdj |
Posted: Mon Feb 12, 2007 7:02 am Post subject: |
|
|
Newbie
Joined: 08 Feb 2007 Posts: 6
|
Next question...
The change was made to set the TargetClient to MQ but there's still header information coming across. Is there something on the JMS side regarding the message format that could be changed? When I put data to this Queue using another COBOL program and then get the data, I don't get this header information which makes me think there should be another change on the sending side. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Feb 12, 2007 7:08 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What does the header information look like?
Does it contain "MQHRF2"? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
nascar8mdj |
Posted: Mon Feb 12, 2007 7:14 am Post subject: |
|
|
Newbie
Joined: 08 Feb 2007 Posts: 6
|
Character:
MDE 4MQSTR
Hex:
DCC4000000040001000FDDEED4440000333323323300000000000000000000000000FFFF
445000020008003100144823900000002007D09D0400000000000000000100000008FFFF |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Feb 12, 2007 7:36 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
Nigelg |
Posted: Mon Feb 12, 2007 8:29 am Post subject: |
|
|
Grand Master
Joined: 02 Aug 2004 Posts: 1046
|
The most likely reason for getting an MDE as msg data rather than subsumed into the MD is that the MQGET is being done with an MD version 1 instead of an MD version 2.
Add this line
Code: |
md.Version = MQMD_VERSION_2;
|
to the getting application in C; you will need the equivalent if the app is not in C. _________________ MQSeries.net helps those who help themselves.. |
|
Back to top |
|
 |
jsware |
Posted: Tue Feb 13, 2007 12:50 am Post subject: |
|
|
 Chevalier
Joined: 17 May 2001 Posts: 455
|
In C the following code will skip the headers:
Code: |
MQMD mqmd;
MQBYTE buffer[8192];
MQLONG dataLen;
int bufferPos = 0;
/* Do your MQGET here */
MQCHAR *currFmt = mqmd.Format;
while(bufferPos < dataLen) {
if(strncmp(currFmt, MQFMT_RF_HEADER, MQ_FORMAT_LENGTH) == 0) {
/* We got an RFH header so skip it. */
MQRFH *rfh = (MQRFH *)(buffer + bufferPos);
currFmt = rfh->Format;
bufferPos += rfh->StrucLength;
} else if(strncmp(currFmt, MQFMT_RF_HEADER_2, MQ_FORMAT_LENGTH) == 0) {
/* We got an RFH2 header so skip it. */
MQRFH2 *rfh2 = (MQRFH2 *)(buffer + bufferPos);
currFmt = rfh2->Format;
bufferPos += rfh2->StrucLength;
} else if(strncmp(currFmt, MQFMT_DEAD_LETTER_HEADER, MQ_FORMAT_LENGTH) == 0) {
/* We've got a Dead letter header so skip it. */
MQDLH *pDLH = (MQDLH *)(buffer + bufferPos);
currFmt = pDLH->Format;
bufferPos += sizeof(MQDLH);
} else {
/* Break out of the skip loop as we've come across an unknown format type. */
break;
}
}
|
At the end, bufferPos is the index to the start of your payload (or unrecognised header). Adapt it to your own language/needs  _________________ Regards
John
The pain of low quaility far outlasts the joy of low price. |
|
Back to top |
|
 |
christian witschel |
Posted: Wed Mar 26, 2008 4:19 am Post subject: |
|
|
Apprentice
Joined: 07 Dec 2005 Posts: 27
|
can someone hint me how to correctly skip rfh and rfh2 headers in java?
The C example above is already very helpfull. However, I do not understand how you know how much bytes to skip until the next header starts.
What is bufferPos += rfh->StrucLength; doing. What is StrucLength?
As far as I know the RFH2 header is not fixed in size as it can contain addtional custom values. |
|
Back to top |
|
 |
|