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 API Support » Invalid Length in RFH2 variable area - data skipped

Post new topic  Reply to topic
 Invalid Length in RFH2 variable area - data skipped « View previous topic :: View next topic » 
Author Message
mqnet
PostPosted: Tue Mar 24, 2009 10:55 pm    Post subject: Invalid Length in RFH2 variable area - data skipped Reply with quote

Newbie

Joined: 24 Mar 2009
Posts: 6

Hello All,

I am using IBM MQ Classes for .Net and built below MQmessage with RFH2 header. However, when the msg is browsed through RFHUtil, it gives me the error "Invalid Length in RFH2 variable area - data skipped".

Here is the code in VB.Net

qMsg = New MQMessage
qMsg.Format = MQC.MQFMT_RF_HEADER_2
qMsg.MessageType = MQC.MQMT_DATAGRAM 'value = 8
qMsg.CharacterSet = 1208
qMsg.Expiry = -1

Dim strMCD As String = "<mcd><Msd>jms_text</Msd></mcd>"
Dim strJMS As String = "<jms><Dst>queue://TAHRTS05/QA.HRIS.RSS.REQUEST</Dst><Tms>1227656333170</Tms><Dlv>0</Dlv></jms>"

'make the lengths multiples of 4
Dim iMCDLen As Integer = (CInt((strMCD.Length - 1) / 4)) * 4 + 4
Dim iJMSLen As Integer = (CInt((strJMS.Length - 1) / 4)) * 4 + 4

'padding of spaces
strMCD = strMCD.PadRight(iMCDLen, " ")
strJMS = strJMS.PadRight(iJMSLen, " ")

qMsg.WriteBytes(MQC.MQRFH_STRUC_ID) 'struc id
qMsg.WriteInt(MQC.MQRFH_VERSION_2) 'version
qMsg.WriteInt(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + iMCDLen + iJMSLen) 'struc length
qMsg.WriteInt(MQC.MQENC_NATIVE) 'encoding
qMsg.WriteInt(MQC.MQCCSI_INHERIT) 'code character set id
qMsg.WriteBytes(MQC.MQFMT_STRING) 'format
qMsg.WriteInt(MQC.MQRFH_NO_FLAGS) 'flags
qMsg.WriteInt(1208) 'name value ccsid

'variable portion
qMsg.WriteLong(iMCDLen)
qMsg.WriteBytes(strMCD)
qMsg.WriteLong(iJMSLen)
qMsg.WriteBytes(strJMS)

qPutMsgOpts = New MQPutMessageOptions
qMsg.WriteBytes("here is the actual text")

Can anyone tell me what am I doing wrong ? I have already spent good amount of time and didn't find any reason of this error .

Thanks for any suggestions.
Back to top
View user's profile Send private message
mqnet
PostPosted: Thu Mar 26, 2009 9:48 am    Post subject: I fixed it myself. Reply with quote

Newbie

Joined: 24 Mar 2009
Posts: 6

Here is the solution.

qMsg = New MQMessage

'************************************************************
' FOR JMS/RFH2 HEADER
'************************************************************
'to set up JMS format - define RFH2 header
'MQMD (Message Descriptor) header
qMsg.Format = MQC.MQFMT_RF_HEADER_2 'format: MQHRF2
qMsg.MessageType = MQC.MQMT_DATAGRAM 'value = 8
qMsg.CharacterSet = 1208
qMsg.Expiry = -1

'RFH header
'Define JMS folders - it has 1) mcd 2) jms
'mcd - Message Content
'Msd - message domain
'jms - jave messaging system
'Dst - Destination
'Tms - Timestamp
'Dlv - Delivery mode
'these strings defined below must be constant, case sensitive and must be exactly the same
Dim strMCD As String = "<mcd><Msd>jms_text</Msd></mcd>"
Dim strJMS As String = "<jms><Dst>queue://" & qManager & "/" & qName & "</Dst><Tms>" & DateTime.Now.ToString("HHmmssffff") & "</Tms><Dlv>2</Dlv></jms>"

'get the byte length of the above strings
Dim strMCDBytes As Byte() = Text.Encoding.ASCII.GetBytes(strMCD)
Dim strJMSBytes As Byte() = Text.Encoding.ASCII.GetBytes(strJMS)
Dim strMsgBytes As Byte() = Text.Encoding.ASCII.GetBytes(message)

'those lengths have to be in multiples of 4
'this can be achieved by adding spaces and making their lengths multiples of 4
Dim iMCDLen As Integer = (CInt((strMCDBytes.Length - 1) / 4)) * 4 + 4 '32
Dim iJMSLen As Integer = (CInt((strJMSBytes.Length - 1) / 4)) * 4 + 4 '96
Dim iMsgLen As Integer = (CInt((strMsgBytes.Length - 1) / 4)) * 4 + 4

'padding of spaces
strMCD = strMCD.PadRight(iMCDLen, " ")
strJMS = strJMS.PadRight(iJMSLen, " ")

'RFH Header - fixed portion
qMsg.WriteString(MQC.MQRFH_STRUC_ID) 'struc id : MQRFH_STRUC_ID
qMsg.WriteInt4(MQC.MQRFH_VERSION_2) 'version : MQC.MQRFH_VERSION_2
'struc length : MQC.MQRFH_STRUC_LENGTH_FIXED_2 + JMS folders(mcd, jms) length + add 4 bytes for each folder mdc - 4, jms - 4
qMsg.WriteInt4(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + iMCDLen + iJMSLen + 4 + 4)
qMsg.WriteInt4(MQC.MQENC_NATIVE) 'encoding : MQC.MQENC_NATIVE
qMsg.WriteInt4(MQC.MQCCSI_INHERIT) 'code character set id : MQC.MQCCSI_INHERIT
qMsg.WriteString(MQC.MQFMT_STRING) 'format: MQSTR
qMsg.WriteInt4(MQC.MQRFH_NO_FLAGS) 'flags: 0
qMsg.WriteInt4(1208) 'name value ccsid : 1208 = UTF-8

''RFH Header - variable portion
qMsg.WriteInt4(iMCDLen) 'namevaluelength
qMsg.WriteString(strMCD) 'namevaluedata
qMsg.WriteInt4(iJMSLen) 'namevaluelength
qMsg.WriteString(strJMS) 'namevaluedata

'************************************************************
'JMS/RFH2 header ends here
'************************************************************

qPutMsgOpts = New MQPutMessageOptions
qMsg.Write(System.Text.Encoding.ASCII.GetBytes(message)) 'actual msg from xml

' Place the message on the queue, using default put message options.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Mar 26, 2009 2:51 pm    Post subject: Reply with quote

Grand High Poobah

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

Or you could use the XMS package that does all the RFH handling for you.
_________________
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 API Support » Invalid Length in RFH2 variable area - data skipped
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.