User Guide : Scripting : Script Objects : RFH Header Support: Websphere MQ
 
Share this page             
RFH Header Support: Websphere MQ
The DJMessage object supports both RFH and RFH2 headers for Websphere MQ. These Rules and Formatting Headers (RFH) contain a fixed binary set of properties followed by a variable set of property values. The differences between the two versions of the RFH headers are discussed below.
RFH Header Guidelines and Properties
The RFH header guidelines only allow for a single header to exist in a message. The fixed binary set of properties is followed by a variable set of name/value pairs.
strucid
version
struclength
encoding
codedcharsetid
format
flags
namevaluestring
RFH2 Header Guidelines and Properties
The RFH2 header guidelines allow for multiple headers to exist in a single message. In addition, the fixed binary portion is followed by a pair of repeating fields: a four-byte field which indicates the length of the data field and the data field. The data field is an XML representation of the data set up in triplets: name, data type and value. In RFH2 headers, there can be multiple variable portions that contain data in XML format.
strucid
version
struclength
encodingcodedcharsetid
format
flags
namevalueccsid
namevaluelength
namevaluedata
Note:  The namevaluelength* and namevaluedata* properties are the only properties that may have more than one occurrence in a header.
Specifying RFH and RFH2 Headers
Because messages can contain multiple RFH2 headers and RFH2 headers can have multiple occurrences of some of their properties, the following scheme specifies the properties.
To specify an RFH header, the property name begins with 'rfh'.
To specify which RFH header in a message is being referenced, the 'rfh' is followed by a period ('.') and then the number of the header, for example: 'rfh.1'.
To specify the property name being referenced, the number is followed by a period ('.') and the name of the property, for example: 'rfh.1.version'.
If there is more than one occurrence of a property, the property name is followed by a period ('.') and the number of the occurrence, for example, 'rfh.1.namevaluedata.1'.
The following property reference is a reference to the third occurrence of the namevaluelength property for the second RFH2 header:
mhandle.properties("rfh.2.namevaluelength.3")
Websphere MQ Header Support
The following examples deal with retrieving header information from the Websphere MQ component. DataConnect supports both the RFH1 and RFH2 header types for Websphere MQ, as well as the MQMD header. In both of the RFH headers, there is a fixed portion that is fixed Binary and the difference between the headers is in the variable length that follows.
Supported Header Types
RFH1: The variable length beyond the fixed header is a set of value pairs.
RFH2: The header is an XML representation of the data, set up in triplets. RFH2 headers can have multiple headers, but RFH1 headers can have only one. RFH2 headers can be header, message, header, message, etc., or multiple headers at the beginning.
Examples
Creating an RFH2 Header
Dim q As DJComponentSet
q = new DJComponent "Websphere MQ"
q.ConnectString = "queue=queue1"
Dim msg as DJMessage
Set msg = new DJMessage "msg1"
msg.Body = "Test Message with RFH2 header."
' The version number for an RFH2 header
msg.Properties( "rfh.1.version" ) = 2
' The length of the header data
msg.Properties( "rfh.1.namevaluelength.1" ) = 11
' The header data
msg.Properties( "rfh.1.namevaluedata.1" ) = "Header data"
q.PutMessage(msg)
Set q = Nothing
Reading an RFH2 Header
Dim q As DJComponent
Set q = new DJComponent "Websphere MQ"
q.ConnectString = "queue=queue1"
Dim msg as DJMessage
Set msg = q.GetMessage()
FileWrite(msg.Properties("rfh.1.version"), MB_OK, "RFH version")
FileWrite(msg.Properties( "rfh.1.namevaluedata.1" ), MB_OK, "RFH header data" )
FileWrite(msg.Body, MB_OK, "Message body" )
Set q = Nothing
For more Websphere MQ technical information, go to the IBM website and click the Websphere MQ links.