Reports and segmented messages
Not supported on IBM® MQ for z/OS®.
If a message is segmented and you ask for reports to be generated, you might receive more reports than you would have done had the message not been segmented.
For a description of segmented messages, see Message segmentation.
For reports generated by IBM MQ
If you segment your messages or allow the queue manager to do so, there is only one case in which you can expect to receive a single report for the entire message. This is when you have requested only COD reports, and you have specified MQGMO_COMPLETE_MSG on the getting application.
In other cases your application must be prepared to deal with several reports; usually one for each segment.
For reports generated by applications
If your application generates reports, always copy the IBM MQ headers that are present at the start of the original message data to the report message data.
Then add none, 100 bytes, or all of the original message data (or whatever other amount you would usually include) to the report message data.
Format names indicate these IBM MQ headers:- MQMDE
- MQDLH
- MQXQH
- MQIIH
- MQH*
The Format name occurs at specific positions for MQDLH and MQXQH, but for the other IBM MQ headers it occurs at the same position. The length of the header is contained in a field that also occurs at the same position for MQMDE, MQIMS, and all MQH* headers.
If you are using a Version 1 MQMD, and you are reporting on a segment, or a message in a group, or a message for which segmentation is allowed, the report data must start with an MQMDE. Set the OriginalLength field to the length of the original message data excluding the lengths of any IBM MQ headers that you find.
Retrieving reports
If you ask for COA or COD reports, you can ask for them to be reassembled for you with MQGMO_COMPLETE_MSG.
An MQGET with MQGMO_COMPLETE_MSG is satisfied when enough report messages (of a single type, for example COA, and with the same GroupId) are present on the queue to represent one complete original message. This is true even if the report messages themselves do not contain the complete original data; the OriginalLength field in each report message gives the length of original data represented by that report message, even if the data itself is not present.
You can use this technique even if there are several different report types present on the queue (for example, both COA and COD), because an MQGET with MQGMO_COMPLETE_MSG reassembles report messages only if they have the same Feedback code. However, you cannot usually use this technique for exception reports, because, in general, these have different Feedback codes.
You can use this technique to get a positive indication that the entire message has arrived. However, in most circumstances you need to cater for the possibility that some segments arrive while others might generate an exception (or expiry, if you have allowed this). You cannot use MQGMO_COMPLETE_MSG in this case, because, in general, you might get different Feedback codes for different segments and, you might get more than one report for a segment. You can, however, use MQGMO_ALL_SEGMENTS_AVAILABLE.
To allow for this you might need to retrieve reports as they arrive, and build up a picture in your application of what happened to the original message. You can use the GroupId field in the report message to correlate reports with the GroupId of the original message, and the Feedback field to identify the type of each report message. The way in which you do this depends on your application requirements.
- Ask for COD reports and exception reports.
- After a specific time, check whether a complete set of COD reports has been received using MQGMO_COMPLETE_MSG. If so, your application knows that the entire message has been processed.
- If not, and exception reports relating to this message are present, handle the problem as for unsegmented messages, but ensure that you clean up orphan segments at some point.
- If there are segments for which there are no reports of any kind, the original segments (or the reports) might be waiting for a channel to be reconnected, or the network might be overloaded at some point. If no exception reports at all have been received (or if you think that the ones you have might be temporary only), you might decide to let your application wait a little longer.
As before, this is similar to the considerations you have when dealing with unsegmented messages, except that you must also consider the possibility of cleaning up orphan segments.
Back-level queue managers
When a report is generated by a queue manager that supports segmentation, but is received on a queue manager that does not support segmentation, the MQMDE structure (which identifies the Offset and OriginalLength represented by the report) is always included in the report data, in addition to zero, 100 bytes, or all of the original data in the message.
However, if a segment of a message passes through a queue manager that does not support segmentation, if a report is generated there, the MQMDE structure in the original message is treated purely as data. It is not therefore included in the report data if zero bytes of the original data have been requested. Without the MQMDE, the report message might not be useful.
Request at least 100 bytes of data in reports if there is a possibility that the message might travel through a back-level queue manager.