lanes
lanes

Reputation: 1937

Getting WebSphere MQ message headers

I want to list the headers of a message. But when I use the code provided by the IBM the loop is never entered:

...
int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF;
MQQueue queue = qMgr.accessQueue(qName, openOptions);
...
MQMessage rcvMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
queue.get(rcvMessage, gmo);
MQHeaderIterator it = new MQHeaderIterator(rcvMessage);
   while (it.hasNext()) {
      MQHeader header = it.nextHeader();
      System.out.println("Header type " + header.type() + ": " + header);
   }
...

Has anyone any idea where my mistake is?

Here is a message read with qload:

A VER 2
A RPT 0
A MST 8
A EXP -1
A FDB 0
A ENC 273
A CCS 819
A FMT
A PRI 0
A PER 0
A MSI 414D5120574D42514D3144312020202035E2165414530020
A COI 000000000000000000000000000000000000000000000000
A BOC 0
A RTQ
A RTM WMBQM1D1
A USR lanes
A ACC 0000000000000000000000000000000000000000000000000000000000000000
A AID
A PAT 28
A PAN mq.MQ
A PTD 20140916
A PTT 11415704
A AOD
A GRP 000000000000000000000000000000000000000000000000
A MSQ 1
A OFF 0
A MSF 0
A ORL -1
X 000D48656C6C6F2C20576F726C6421

Upvotes: 1

Views: 5114

Answers (1)

lanes
lanes

Reputation: 1937

Calanais gave the answer: the message descriptors aren't classed as header.

Here is a table of headers:

Header  Header Description  Format Name

MQCIH   CICS information header MQFMT_CICS
MQDLH   Dead-letter header  MQFMT_DEAD_LETTER_HEADER
MQDH    Distribution-list header    MQFMT_DIST_HEADER
MQEPH   Embedded PCF header MQFMT_EMBEDDED_PCF
MQIIH   IMS information header  MQFMT_IMS
MQMDE   Message-descriptor extension    MQFMT_MD_EXTENSION
MQCFH   PCF header  MQFMT_ADMIN / MQFMT_EVENT / MQFMT_PCF
MQRMH   Reference message header    MQFMT_REF_MSG_HEADER
MQRFH   Formatting header   MQFMT_RF_HEADER
MQRFH2  Version-2 rules and formatting header   MQFMT_RF_HEADER_2
MQWIH   Work information header MQFMT_WORK_INFO_HEADER
MQXQH   Transmission queue header   MQFMT_XMIT_Q_HEADER

If you want to read the MQMD fields see here.

Upvotes: 2

Related Questions