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 we 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 the application must be prepared to deal with several reports; usually one for each segment.
Note: If you segment your messages, and we need only the first 100 bytes of the original message data to be returned, change the setting of the report options to ask for reports with no data for segments that have an offset of 100 or more. If we do not do this, and you leave the setting so that each segment requests 100 bytes of data, and you retrieve the report messages with a single MQGET specifying MQGMO_COMPLETE_MSG, the reports assemble into a large message containing 100 bytes of read data at each appropriate offset. If this happens, we need a large buffer or we need to specify MQGMO_ACCEPT_TRUNCATED_MSG.For reports generated by applications
If the 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.
We can recognize the IBM MQ headers that must be copied by looking at the successive Format names, starting with the MQMD and continuing through any headers present. The following Format names indicate these IBM MQ headers:MQH* means any name that starts with the characters 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 we are using a Version 1 MQMD, and we 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, we 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.
We 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, we cannot usually use this technique for exception reports, because, in general, these have different Feedback codes.
We can use this technique to get a positive indication that the entire message has arrived. However, in most circumstances we need to cater for the possibility that some segments arrive while others might generate an exception (or expiry, if you have allowed this). We 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. We 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 the application of what happened to the original message. We 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 the application requirements.
One approach is as follows:- 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, the 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 the application wait a little longer.
As before, this is similar to the considerations you have when dealing with unsegmented messages, except that we must also consider the possibility of cleaning up orphan segments.
If the original message is not critical (for example, if it is a query, or a message that can be repeated later), set an expiry time to ensure that orphan segments are removed.
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.
Parent topic: Types of message