Handling IBM MQ message headers with IBM MQ classes for Java
Java™ classes are provided representing different types of message header. Two helper classes are also provided.
The MQHeader interface
Header objects are described by the MQHeader interface, which provides general-purpose methods for accessing header fields and for reading and writing message content. Each header type has its own class that implements the MQHeader interface and adds getter and setter methods for individual fields. For example, the MQRFH2 header type is represented by the MQRFH2 class; the MQDLH header type by the MQDLH class, and so on. The header classes perform any necessary data conversion automatically, and can read or write data in any specified numeric encoding or character set (CCSID).
- The MQHeaderIterator class works like a java.util.Iterator. For as long as there are more headers in the message, the next() method returns true, and the nextHeader() or next() method returns the next header object.
- The MQHeaderList works like a java.util.List. Like the MQHeaderIterator, it parses header content, but it also allows you to search for particular headers, add new headers, remove existing headers, update header fields and then write the header content back to a message. Alternatively, you can create an empty MQHeaderList, then populate it with header instances and write it to a message once or repeatedly.
- MQRFH - Rules and formatting header
- MQRFH2 - Like MQRFH, used to pass messages to and from a message broker belonging to IBM Integration Bus. Also used to contain message properties
- MQCIH - CICS® Bridge
- MQDLH - Dead letter header
- MQIIH - IMS information header
- MQRMH - reference message header
- MQSAPH - SAP header
- MQWIH - Work information header
- MQXQH - Transmission Queue header
- MQDH - Distribution header
- MQEPH - Encapsulated PCF header
To use an MQHeaderIterator to get an RFH2 header, either set MQGMO_PROPERTIES_FORCE_MQRFH2 in the GetMessageOptions, or set the queue property PROPCTL to FORCE.