The Print Message sample on z/OS
The Print Message sample is a batch application that demonstrates how to remove all the messages from a queue using the MQGET call.
The Print Message sample uses three parameters:- The name of the queue manager
- The name of the source queue
- An optional parameter for properties
It also prints, for each message, the fields of the message descriptor, followed by the message data. The program prints the data both in hexadecimal and as characters (if they are printable). If a character is not printable, the program replaces it with a period character (.). We can use the program when diagnosing problems with an application that is putting messages on a queue.
Permissible values for the property parameter are:
Value | Behavior |
---|---|
0 | Default behavior, as it was for Version 6. The properties that get delivered to the application depend on the PropertyControl queue attribute that the message is retrieved from. |
1 | A message handle is created and used with the MQGET. Properties of the message,
except those contained in the message descriptor (or extension) are displayed in a similar fashion
to the message descriptor. For example:
****Message properties**** property name: property valueOr if no properties are available: ****Message properties**** NoneNumeric values are displayed using printf, string values are surrounding in single quotation marks, and byte strings are surrounded with X and single quotation marks, as for the message descriptor. |
2 | MQGMO_NO_PROPERTIES is specified, so that only message descriptor properties will be returned. |
3 | MQGMO_PROPERTIES_FORCE_MQRFH2 is specified, so that all properties are returned in the message data. |
4 | MQGMO_PROPERTIES_COMPATIBILITY is specified, so that all properties can be returned depending on whether a Version 6 property is included, otherwise the properties are discarded. |
We can change the application so that it browses the messages, rather than removing them from the queue. To do this, compile with the option of -DBROWSE, to define the BROWSE macro, as indicated in Design of the Print Message sample on z/OS. Executable code is provided for you in the SCSQLOAD library. Module CSQ4BCG0 is built with -DBROWSE; module CSQ4BCG1 destructively reads the queue.
The application has a single source program, which is written in the C language. Sample run JCL code is also supplied (see Table 3 ). To start the application, edit and run the sample run JCL, as described in Preparing and running sample applications for the batch environment on z/OS. When you run the application (and there are some messages on the queue), the output data set looks like that in Figure 1.