Using the WebSphere MQ Headers package

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

About this task

The WebSphere MQ Headers package is located in the com.ibm.mq.headers and com.ibm.mq.pcf packages. You can use this facility for both of the two alternative APIs that WebSphere MQ provides for use in Java applications:
  • WebSphere MQ classes for Java (also referred to as WebSphere MQ Headers Base Java).
  • WebSphere MQ classes for Java Message Service ( WebSphere MQ classes for JMS, also referred to as WebSphere MQ JMS).

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

In WebSphere 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 WebSphere 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 WebSphere MQ JMS applications.

Therefore, although the WebSphere MQ Headers package contains references to the WebSphere MQ Base Java package, it is also intended for use within WebSphere 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 WebSphere 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 a WebSphere MQ resource.
  • To monitor the depth of a queue.
  • To inhibit access to a queue.
By using PCF messages with the WebSphere 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 WebSphere MQ Base Java API.