Finding a specific type of header in a message using IBM MQ classes for Java
This example uses the indexOf(String) method of MQHeaderList to find an MQRFH2 header in a message, if one is present.
import com.ibm.mq.MQMessage; import com.ibm.mq.headers.MQHeaderList; import com.ibm.mq.headers.MQRFH2; ... MQMessage message = ... MQHeaderList list = new MQHeaderList (message); int index = list.indexOf ("MQRFH2"); if (index >= 0) { MQRFH2 rfh = (MQRFH2) list.get (index); ... }Parent topic: Handling IBM MQ message headers with IBM MQ classes for Java