ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQRHF2 Header Error - Invalid Length in RFH2

Post new topic  Reply to topic
 MQRHF2 Header Error - Invalid Length in RFH2 « View previous topic :: View next topic » 
Author Message
Java_Problem
PostPosted: Wed Jul 16, 2008 5:45 am    Post subject: MQRHF2 Header Error - Invalid Length in RFH2 Reply with quote

Newbie

Joined: 16 Jul 2008
Posts: 9

Hello ALL,

I am using IBM RFHUtil to read the message from WebSphere MQ Server for the message that I posted using MQRHF2 header.

However, when I try to retrieve the message using RFHUtil - I get error as - "Invalid Length in RFH2 variable area - data skipped"

Below is the code snippet that i use to write the header

dos = new DataOutputStream(os);
dos.writeBytes(MQC.MQRFH_STRUC_ID); // MQCHAR4 - StrucId = 'RFH '
dos.writeInt(MQC.MQRFH_VERSION_2); // MQLONG - Version = x'00000002'
dos.writeInt(len); // MQLONG - StrucLen must be multiple of 4 (data in NameValueData fields can be padded with space to achieve this)
dos.writeInt(MQC.MQENC_NATIVE); // MQLONG - Encoding of data that follows the last NameValueData field - does not apply to numeric data in RFH2 itself.
dos.writeInt(MQC.MQCCSI_INHERIT); // MQLONG - CodedCharSetId of data that follows the last NameValueData field.
dos.writeBytes(fmt); // MQCHAR8 - Format name of data that following last NameValueData - MUST MATCH MQMD.format field
dos.writeInt(MQC.MQRFH_NO_FLAGS); // MQLONG - Flags
dos.writeInt(1208); // MQLONG - NaveValueCCSID = UTF-8 may need a way to allow changing this

Thanks for any suggestiion as I have already spend good amount of time and didn't find any reason of this error

Thanks again
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed Jul 16, 2008 11:11 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I didn't look at your code, but I know that at:

http://www-304.ibm.com/jct09002c/isv/tech/sampmq.html

There is a sample (jsmqput.c) that does what you are trying.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Java_Problem
PostPosted: Wed Jul 16, 2008 1:02 pm    Post subject: Reply with quote

Newbie

Joined: 16 Jul 2008
Posts: 9

Well - Thanks for the URL

But honestly, I am still far from the solution
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 16, 2008 1:17 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Java_Problem wrote:
Well - Thanks for the URL

But honestly, I am still far from the solution

That's why I would not bother with base java if I need an RFH header.
I woud just use JMS.
_________________
MQ & Broker admin


Last edited by fjb_saper on Wed Jul 16, 2008 6:42 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
sridhsri
PostPosted: Wed Jul 16, 2008 2:07 pm    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

I found this piece of code some time ago in this forum

MQMessage oMsg = new MQMessage();

oMsg.format = CMQC.MQFMT_RF_HEADER_2;
oMsg.setVersion(CMQC.MQMD_VERSION_2);

oMsg.writeString(CMQC.MQRFH_STRUC_ID); // StrucId
oMsg.writeInt4(CMQC.MQRFH_VERSION_2); // Version
oMsg.writeInt4(CMQC.MQRFH_STRUC_LENGTH_FIXED_2 + .....you need to add the variable length here and make it divisible by four...);
oMsg.writeInt4(CMQC.MQENC_NATIVE); // Encoding
oMsg.writeInt4(CMQC.MQCCSI_DEFAULT); // CodedCharacterSetId
oMsg.writeString(CMQC.MQFMT_NONE); // Format (content)
oMsg.writeInt4(CMQC.MQRFH_NO_FLAGS); // Flags
oMsg.writeInt4(1208); // NameValueCCSID = UTF-8
oMsg.writeIn4(<header length>);//usr defined header length
oMsg.writeString(<header content>);//usr defined header

oMsg.writeBytes(content);//message body
Back to top
View user's profile Send private message
Java_Problem
PostPosted: Thu Jul 17, 2008 5:51 pm    Post subject: Reply with quote

Newbie

Joined: 16 Jul 2008
Posts: 9

First of all thanks for all the inputs

But I got confused when you say I would have used JMS instead of Java.

What is the difference between the two ways of creating the RFH2 header. I know i used DataoutputStream to create the header, but how will it make any difference and if it does, I don't mind converting it to some other format if I can get rid of the error that i have been facing since last 5 days

Please help
Back to top
View user's profile Send private message
sridhsri
PostPosted: Thu Jul 17, 2008 7:09 pm    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

WebSphere MQ provides MQ-Java APIs (the ones you have used) to communicate with the qmgr (com.ibm.mq.*). WebSphere MQ is also a JMS provider. So, it supports the JMS APIs (com.ibm.mqjms.*).
Back to top
View user's profile Send private message
Java_Problem
PostPosted: Fri Jul 18, 2008 4:30 am    Post subject: Reply with quote

Newbie

Joined: 16 Jul 2008
Posts: 9

Oh, I see, Thanks for this clarification. Well, again my question is - How does it make a difference or does it? I actually see a lot of places code like the way I wrote down but for some reasons I am getting - Invalid Length in RFH2 variable area - data skipped error.

I even tested the part of making sure that the length is multiple of 4 (it is coming as 88 - so that makes it multiple of 4)

Please advise

Thanks a lot
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jul 18, 2008 7:00 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

The JMS API handles the RFH2 header behind the scenes.
The attribute targetClient of the Destination determines the presence of the RFH header on the message.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Java_Problem
PostPosted: Fri Jul 18, 2008 7:51 am    Post subject: Reply with quote

Newbie

Joined: 16 Jul 2008
Posts: 9

Hello ALL,

Thanks for all your inputs. But I started on this on Monday and I have already spend 5 days with this code. I made all necessary changes and I think I need help if someone can do the same to just see if they too get the error.

My message on the console is getting printed out correctly and gets in Websphere MQ correctly too, it's just when I try to retrieve using IBM RFHUtil I get this error - Invalid Length in RFH2 variable area - data skipped.

For reasons, I cannot change from DataoutputStream . I have to return the header as OutputStream only

Thanks for all your help
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Sun Jul 20, 2008 1:50 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Java_Problem wrote:
But I started on this on Monday and I have already spend 5 days with this code. I made all necessary changes and I think I need help if someone can do the same to just see if they too get the error.

Java_Problem wrote:
it's just when I try to retrieve using IBM RFHUtil I get this error - Invalid Length in RFH2 variable area - data skipped.

Obviously, the following line from your code is wrong. Setting the correct header length is complicated.

Java_Problem wrote:
dos.writeInt(len); // MQLONG - StrucLen must be multiple of 4 (data in NameValueData fields can be padded with space to achieve this)


See the following example for an example on how to calculate the header length (and the appropriate align to a 4-byte boundary).
http://www.mqseries.net/phpBB2/viewtopic.php?t=35456


Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
Java_Problem
PostPosted: Mon Jul 21, 2008 12:52 pm    Post subject: Reply with quote

Newbie

Joined: 16 Jul 2008
Posts: 9

I changed the variable RFH2 header to fixed length - MQC.MQRFH_STRUC_LENGTH_FIXED_2. After this change, the MQ messages starts getting pulled up properly.



I have tried all other permutations (by keeping the variable length and changing other constant values) but either I get the compile error or the error stays the same. Only after I changed to fixed length of RFH2 header, I can see the messages getting printed out in RFH Utility.



The important point to note here is that the variable length is correct multiple of 4 and returns a valid String of folders (<mcd>) in all cases. In spite of that, the RFH Utility errors out with Invalid Length in RFH2 variable area – data skipped error. This is inconsistent with the expected behavior (per MQ documentation) of showing RFH2 data.



If you have any suggestions or inputs, please do share back
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jul 21, 2008 2:31 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

If you want the quick trouble shooting method:
Create the RFH header using either RFHUtil or JMS.
Compare byte to byte with one you created manually and find the difference...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQRHF2 Header Error - Invalid Length in RFH2
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.