The Print Message sample is a simple batch application that demonstrates how to remove all the messages from a queue using the MQGET call. 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 (.). You can use the program when diagnosing problems with an application that is putting messages on a queue.
You can change the application so that it browses the messages, rather than removing them from the queue. To do this, remove the comment characters from two lines in the code, as indicated in Design of the sample.
The application has a single source program, which is written in the C language. Sample run JCL code is also supplied (see Table 47).
To start the application, you must edit and run the sample run JCL, as described in Preparing and running sample applications for the batch environment. When you run the application (and there are some messages on the queue), the output data set looks like that in Figure 42.
Figure 42. Example of a report from the Print Message sample application
MQCONN to VC4 MQOPEN - 'CSQ4SAMP.DEAD.QUEUE' MQGET of message number 1 ****Message descriptor**** StrucId : 'MD ' Version : 1 Report : 0 MsgType : 2 Expiry : -1 Feedback : 0 Encoding : 785 CodedCharSetId : 500 Format : ' ' Priority : 3 Persistence : 0 MsgId : X'C3E2D840E5C3F4404040404040404040A6FE06A95105C620' CorrelId : X'C3E2D840E5C3F4404040404040404040A6FE062950C2F125' BackoutCount : 0 ReplyToQ : ' ' ReplyToQMgr : 'VC4 ' ** Identity Context UserIdentifier : 'CICSUSER ' Account.Token : X'160DD5E3E2D5C5E34BC9C7D7C2F6F1FE060D3B55B60001000000000000000000' ApplIdentData : ' ' ** Origin Context PutApplType : '1' PutApplName : 'VICAUT4 MVB5 ' PutDate : '19930203' PutTime : '20165982' ApplOriginData : ' ' **** Message **** length - 429 bytes 00000000: C3E2 D8F4 C2D8 D9D4 4040 4040 4040 4040 'CSQ4BQRM ' 00000010: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000020: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000030: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000040: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000050: 4040 4040 4040 40D1 D6C8 D540 D140 4040 ' JOHN J ' 00000060: 4040 4040 4040 4040 4040 40F1 F2F3 F4F5 ' 12345' 00000070: F6F7 F8F9 C6C9 D9E2 E340 C7C1 D3C1 C3E3 '6789FIRST GALACT' 00000080: C9C3 40C2 C1D5 D240 4040 4040 4040 4040 'IC BANK ' 00000090: 4040 E2D6 D4C5 E3C8 C9D5 C740 C4C9 C6C6 ' SOMETHING DIFF' 000000A0: C5D9 C5D5 E340 4040 4040 4040 4040 4040 'ERENT ' 000000B0: F3F5 F0F1 F6F7 F6F2 F1F2 F1F0 F0F0 F0F0 '3501676212100000' 000000C0: D985 A297 9695 A285 4086 9996 9440 C3E2 'Response from CS' 000000D0: D8F4 E2C1 D4D7 4BC2 F74B D4C5 E2E2 C1C7 'Q4SAMP.B7.MESSAG' 000000E0: C5E2 4040 4040 4040 4040 4040 4040 4040 'ES ' 000000F0: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000100: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000110: 4040 4040 40D3 9681 9540 8194 96A4 95A3 ' Loan amount' 00000120: 40F1 F0F0 F0F0 F040 8696 9940 D1D6 C8D5 ' 100000 for JOHN' 00000130: 40D1 4040 4040 4040 4040 4040 4040 4040 ' J ' 00000140: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000150: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 00000160: 4040 4040 C399 8584 89A3 40A6 9699 A388 ' Credit worth' 00000170: 8995 85A2 A240 8995 8485 A740 6040 C2C1 'iness index - BA' 00000180: C440 4040 4040 4040 4040 4040 4040 4040 'D ' 00000190: 4040 4040 4040 4040 4040 4040 4040 4040 ' ' 000001A0: 4040 4040 4040 4040 4040 4040 40 ' ' No more messages MQCLOSE MQDISC |
The Print message sample application uses a single program written in the C language.
The flow through the program logic is:
On input to this call, the program uses the connection handle returned in step 2. For the object descriptor structure (MQOD), it uses the default values for all the fields except the queue name (which was passed in step 1). If this call is not successful, print the completion and reason codes and stop processing; otherwise, print the name of the queue.