+

Search Tips | Advanced Search

Use the IBM MQ Headers package

The IBM MQ Headers package provides a set of helper interfaces and classes used to manipulate the IBM MQ headers of a message. Typically, we use the IBM MQ Headers package because we want to perform administrative services by using the command server (by using Programmable Command Format (PCF) messages).


About this task

The IBM MQ Headers package is located in the com.ibm.mq.headers and com.ibm.mq.headers.pcf packages. We can use this facility for both of the two alternative APIs that IBM MQ provides for use in Java applications:

  • IBM MQ classes for Java (also referred to as IBM MQ Base Java).
  • IBM MQ classes for Java Message Service (IBM MQ classes for JMS, also referred to as IBM MQ JMS).

IBM MQ Base Java applications typically manipulate MQMessage objects, and the Headers support classes can directly interact with these objects, since they natively understand the IBM MQ Base Java interfaces.

In IBM MQ JMS, the payload for a message is typically a String or a byte array object, which can be manipulated with DataInput and DataOutput streams. The IBM MQ Headers package can be used to interact with these data streams and is suitable for manipulating any MQ messages that are sent and received by IBM MQ JMS applications.

Therefore, although the IBM MQ Headers package contains references to the IBM MQ Base Java package, it is also intended for use within IBM MQ JMS applications and is suitable for use within Java Platform, Enterprise Edition (Java EE) environments.

A typical way in which you might use the IBM MQ Headers package is to manipulate administration messages in Programmable Command Format (PCF), for example for any of the following reasons:

  • To access details about an IBM MQ resource.
  • To monitor the depth of a queue.
  • To inhibit access to a queue.

By using PCF messages with the IBM MQ JMS API, this kind of administration of application-centric resources can be performed from within Java EE applications without having to resort to using the IBM MQ Base Java API.

  • Use with IBM MQ classes for Java
    IBM MQ classes for Java applications typically manipulate MQMessage objects, and the Headers support classes can directly interact with these objects, since they natively understand the IBM MQ classes for Java interfaces.
  • Use with IBM MQ classes for JMS
    To use the IBM MQ Headers with the IBM MQ classes for JMS, you carry out the same essential steps as for IBM MQ classes for Java. The PCF message can be created and the response parsed in exactly the same way by using the IBM MQ Headers package and the same sample code as for IBM MQ classes for Java.

Parent topic: Developing JMS and Java applications

Last updated: 2020-10-04