Author |
Message
|
ThomasT |
Posted: Wed Jun 17, 2009 2:13 am Post subject: RFH2 header causes 2334 - how to debug? |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
Hi,
I try to build a RFH2 header by myself using the Java-MQ-API (not JMS).
I got a 2334 reason code when putting the message.
I cannot see what was wrong. But the problem is, I don't know how to debug what is wrong.
My Header looks like this:
RFH ” MQSTR 3 <mcd><Msd>jms_bytes</Msd></mcd> H<jms><Exp>0</Exp><Pri>0</Pri><Dlv>0</Dlv><Tms>0</Tms><Seq>0</Seq></jms>
Is this correct so far? (except the bytes you dont see...but I'm assuming the xml-snippets are wrong.)
Thanks for help
Thomas |
|
Back to top |
|
 |
vol |
Posted: Wed Jun 17, 2009 2:21 am Post subject: |
|
|
Acolyte
Joined: 01 Feb 2009 Posts: 69
|
it is much more likely that the unseen bits are wrong. the XML is not parsed, only the header values.
Post a hex dump of the header. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jun 17, 2009 2:27 am Post subject: Re: RFH2 header causes 2334 - how to debug? |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ThomasT wrote: |
I try to build a RFH2 header by myself using the Java-MQ-API (not JMS). |
Why not use JMS? Why reinvent the wheel?
ThomasT wrote: |
I got a 2334 reason code when putting the message.
I cannot see what was wrong. But the problem is, I don't know how to debug what is wrong. |
I'd guess the field alignment is wrong. The unseen bits. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Jun 17, 2009 2:29 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Its hard to tell when we cant see all the bytes! My first response is to ensure the fields are padded correctly according to the MQRFH2 specification (which requires the lengths of some of the folders to be multiples of 4).
Code has been posted on this forum on how to create the headers using non jms apis. Have a search for this as it should be useful to you.
Why cant you use the jms apis? |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Jun 17, 2009 2:37 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
|
Back to top |
|
 |
ThomasT |
Posted: Wed Jun 17, 2009 3:15 am Post subject: |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
Hi,
here the byte dump.
Code: |
52 46 48 20 00 00 00 02 00 00 00 94 00 00 01 11
00 00 00 00 4d 51 53 54 52 20 20 20 00 00 00 00
00 00 03 33 00 00 00 20 3c 6d 63 64 3e 3c 4d 73
64 3e 6a 6d 73 5f 62 79 74 65 73 3c 2f 4d 73 64
3e 3c 2f 6d 63 64 3e 20 00 00 00 48 3c 6a 6d 73
3e 3c 45 78 70 3e 30 3c 2f 45 78 70 3e 3c 50 72
69 3e 30 3c 2f 50 72 69 3e 3c 44 6c 76 3e 30 3c
2f 44 6c 76 3e 3c 54 6d 73 3e 30 3c 2f 54 6d 73
3e 3c 53 65 71 3e 30 3c 2f 53 65 71 3e 3c 2f 6a
6d 73 3e 20 54 68 fc 73 20 69 73 20 f6 6e 6c 79
20 61 20 74 e4 73 74 2e
|
[/code] |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jun 17, 2009 3:45 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Well there you have it.
You've still not explained why you're trying to re-invent the wheel with this. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
ThomasT |
Posted: Wed Jun 17, 2009 3:54 am Post subject: |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
There are differnent kind of wheels, so inventing a one can make sense...
I used the normal API because I thought (indeed still think) it would give me more and better access to MQ. E.g. with a JMSTextmessage it seems not to have access to the raw bytes.
Maybe I'm wrong.
But It should be possible to program it myself. I simply cannot see the problem. I think I've done all right.
Of couse I looked successfully for some code snippets here. So I'm inventing the wheel but not all spokes ... |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jun 17, 2009 4:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ThomasT wrote: |
There are differnent kind of wheels, so inventing a one can make sense... |
Granted, but standards become standards for a reason.
ThomasT wrote: |
I used the normal API because I thought (indeed still think) it would give me more and better access to MQ. E.g. with a JMSTextmessage it seems not to have access to the raw bytes. |
No, a text message is deliberately presented as a string. If you want binary data you use JMSBytemessage (or however it's spelt).
ThomasT wrote: |
Maybe I'm wrong. |
I certainly struggle to see what "better" access to WMQ you'll get via the native interface especially as you're trying to manipulate the RFH2, who's principle purpose in native WMQ is to hold JMS properties that don't fit in the MQMD.
ThomasT wrote: |
But It should be possible to program it myself. I simply cannot see the problem. I think I've done all right. |
It is possible but seldom worth the effort, the problem is the alignment is wrong and no you haven't _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
ThomasT |
Posted: Wed Jun 17, 2009 4:15 am Post subject: |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
|
Back to top |
|
 |
Vitor |
Posted: Wed Jun 17, 2009 4:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ThomasT wrote: |
*what* exactly is wrong? |
WMBDEV1 wrote: |
ensure the fields are padded correctly according to the MQRFH2 specification (which requires the lengths of some of the folders to be multiples of 4). |
_________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Jun 17, 2009 7:32 am Post subject: Re: RFH2 header causes 2334 - how to debug? |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
ThomasT wrote: |
I try to build a RFH2 header by myself using the Java-MQ-API (not JMS).
|
Manually creating a RFH2 header (outside of JMS) is complex. You have to worry about 4-byte alignment, padding, setting section length values, etc...
Read the last couple of comments in the following posting and it should shed some light on your mistakes:
http://www.mqseries.net/phpBB2/viewtopic.php?t=14224
Regards,
Roger Lacroix
Capitalware inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
ThomasT |
Posted: Wed Jun 17, 2009 8:02 am Post subject: |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
I read the original documentation, I searched in the forum (code snippet, tipps), I reverse-engineered a JMS header. All I can see is that there is no error, all values correct an on the right place. But there *must* be a mistake...
It tried to add no named parts at all. -> 2334
It tried to add two dummy named parts with each one byte 0x55 and 0x56.
Each with a 4byte integer with value 1 for its length before.
Of course the RFH2 StrucLength was set to 46 (decimal).
-> 2334.
Someone wrote that the named parts are not parsed. So it should work, doesn't it?
Writing an RFH2-Header is less complicated that e.g. a TIFF-Image. Well...it should...;-(
My code is this:
Code: |
public void createAndWrite(final MQMessage mQmessage, final Message input) throws IBMMQException{
try
{
//create header
rfhStrucID = MQC.MQRFH_STRUC_ID;
rfhVersion = MQC.MQRFH_VERSION_2;
rfhStrucLength = MQC.MQRFH_STRUC_LENGTH_FIXED_2; //==36
rfhEncoding = MQC.MQENC_NATIVE;
rfhCodedCharSetId = MQC.MQCCSI_DEFAULT;
rfhFormat = input.getText() != null ? MQC.MQFMT_STRING : MQC.MQFMT_NONE;
rfhFlags = 0; //MQC.MQRFH_NO_FLAGS
rfhNameValueCCSID = 819; //1208 - UTF-8
//create XML-snippets
mcd = RFH2_MCD.create(input);
jms = RFH2_JMS.create(input);
usr = RFH2_USR.create(input);
//create bytes of XML-snippets (they have already lengths of mulitples of 4)
final byte[] mcdBytes = mcd.getBytes(rfhNameValueCCSID);
final byte[] jmsBytes = jms.getBytes(rfhNameValueCCSID);
final byte[] usrBytes = usr != null ? usr.getBytes(rfhNameValueCCSID) : null;
if (mcdBytes != null) rfhStrucLength += mcdBytes.length + 4; //4 bytes of length integer
if (jmsBytes != null) rfhStrucLength += jmsBytes.length + 4; //4 bytes of length integer
if (usrBytes != null) rfhStrucLength += usrBytes.length + 4; //4 bytes of length integer
//write header
mQmessage.writeString(rfhStrucID);
mQmessage.writeInt4(rfhVersion);
mQmessage.writeInt4(rfhStrucLength);
mQmessage.writeInt4(rfhEncoding);
mQmessage.writeInt4(rfhCodedCharSetId);
mQmessage.writeString(rfhFormat);
mQmessage.writeInt4(rfhFlags);
mQmessage.writeInt4(rfhNameValueCCSID);
//write XML-snippets and their lengths
if (mcdBytes != null){
mQmessage.writeInt4(mcdBytes.length);
mQmessage.write(mcdBytes);
}
if (jmsBytes != null){
mQmessage.writeInt4(jmsBytes.length);
mQmessage.write(jmsBytes);
}
if (usrBytes != null){
mQmessage.writeInt4(usrBytes.length);
mQmessage.write(usrBytes);
}
}
catch (IOException ioex){
throw new IBMMQException(ERRCODE_CREATING_RFH2, ERRMSG_CREATING_RFH2, ioex);
}
}
|
|
|
Back to top |
|
 |
ThomasT |
Posted: Wed Jun 17, 2009 8:37 am Post subject: Solution found! |
|
|
Novice
Joined: 23 Apr 2006 Posts: 12
|
Code: |
rfhCodedCharSetId = MQC.MQCCSI_DEFAULT; |
This was the problem. It seems 0 is not allowed here. Changing this to
Code: |
rfhCodedCharSetId = 819; |
works nearly perfectly...until the next bug I'll found now... |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Jun 17, 2009 8:58 am Post subject: Re: Solution found! |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
ThomasT wrote: |
Code: |
rfhCodedCharSetId = MQC.MQCCSI_DEFAULT; |
This was the problem. It seems 0 is not allowed here. Changing this to
Code: |
rfhCodedCharSetId = 819; |
|
Actually, you should be doing:
Code: |
rfhCodedCharSetId = MQC.MQCCSI_INHERIT; |
Also, why are you converting MCD, JMS & USR folders to byte arrays? They should be string (aligned on a 4-byte boundary and padded with blanks - if necessary).
i.e.
http://www.mqseries.net/phpBB/viewtopic.php?p=248595
Regards,
Roger Lacroix
Capitalware inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
|