MQRFH2 is how IBM MQ carries extra properties on a message without cramming them into the business payload. Integration middleware and JMS clients wrap JSON or XML in a buffer that starts with one or more headers: MQRFH2 folders hold string tags like content type, reply queue hints, trace identifiers, and broker routing instructions. A COBOL program doing plain MQGET sees unfamiliar bytes before the expected copybook—those bytes are often RFH2, not corruption. Publishers on topics may embed RFH2 so subscribers filter on properties. This tutorial explains header layout at a beginner level, common folders (mqmd, mcd, jms, usr), how RFH2 chains with MQMD Format, length calculation on MQPUT, consumer strategies to skip or parse, MQRFH versus obsolete RFH1, and troubleshooting property loss across channels.
A message on the wire and in the queue file logically contains: MQMD (descriptor, separate structure in API), then optional headers (MQRFH2, MQDLH for dead letter, etc.), then application data. In a single MQPUT buffer for header APIs, bytes are concatenated: RFH2 structure followed by payload. MQMD.Format may be MQFMT_RF_HEADER_2 or a string indicating embedded headers per IBM patterns. Total message length on MQPUT includes header plus body. MAXMSGL must accommodate the sum—channels reject oversize totals.
| Folder | Typical content |
|---|---|
| mcd | Message context: Set, Type, Format hints for brokers |
| jms | JMS properties: destination, delivery mode, timestamp |
| usr | User-defined name-value pairs for apps |
| mqtrace | Distributed trace correlation IDs |
| amq | IBM MQ internal/administrative tags in some tools |
MQRFH2 starts with StrucId RFH and Version MQRFH_VERSION_2. Flags control parsing. NameValueStringLength and NameValueStringCount describe the property bag. Each property is a length-prefixed name and value in UTF-8 or configured encoding. Building by hand in C requires careful length arithmetic—off-by-one causes 2014 or truncation. JMS setStringProperty becomes RFH2 entries transparently to the developer.
1234567Logical layout (conceptual): [ MQMD - separate parameter in MQI ] [ MQRFH2 block | optional additional headers ] [ Application payload - JSON, XML, COBOL bytes ] Consumer must know whether RFH2 is present before parsing payload.
MQMD is the official shipping label. MQRFH2 is extra sticky notes brokers stick on saying things like "deliver express" or "JMS reply queue name" that are not part of the letter inside the envelope.
When Java JMS sends TextMessage, the client typically inserts RFH2 with jms folder fields. IBM App Connect and IIB map message trees to RFH2 for routing nodes. Changing middleware version can add properties—regression test binary layout when upgrading. Request/reply over JMS still uses CorrelId in MQMD; JMSCorrelationID maps to messaging layer.
Publishers attach user properties for selective subscription matching in advanced scenarios. Subscribers using bare MQI must parse usr folder or use MQ subscription API that exposes properties. Retained publications may include RFH2 metadata surviving restart per topic configuration.
Some clients offer MQGET with properties separated—prefer supported API over manual parse when available. MQGMO_PROPERTIES_COMPATIBILITY affects behavior on certain platforms.
Legacy MQRFH (version 1) appears in old integrations. Modern paths use RFH2 exclusively. Mixing versions across partners causes parse failures—standardize on RFH2 in interface specifications.
Messages hitting DLQ may include MQDLH (dead-letter header) describing failure reason in addition to RFH2. Support teams read DLH Reason field plus original MQMD. Do not strip headers when requeueing without understanding discard rules.
Large property bags inflate every message and CPU on parse. Keep usr properties minimal. Binary payload belongs in body, not duplicated in properties. Monitor channel bytes versus business bytes ratio in capacity planning.
MQRFH2 is extra notes on the outside of your letter package telling delivery robots special instructions before they hand you the real letter inside.
Document your interface: does production traffic include RFH2? How do COBOL consumers know?
List three jms folder properties you would expect from a JMS TextMessage put.
Why must MAXMSGL include header plus body length?
1. MQRFH2 carries:
2. JMS messages often include:
3. MQMD versus MQRFH2:
4. Raw C consumer of JMS producer must: