Practical mastering IBM MQ basics
Message descriptor (MQMD V2) (1)
*This series may be revised based on the latest mqpgf/mqpcf. Please always download and use the latest version.
Overview of MQMD V2
In communication using MQ, use a function called "logical message grouping" when you need to order multiple messages or process multiple messages on the same machine. In addition, a function called "Message Segmentation" is provided in case you want to divide the message into a fixed size, such as the requirement to transfer large size data in MQ message. These features are associated with the fields added in MQMD V2. There is a restriction on the maximum length of physical messages that can be handled by MQ, and it is set by MAXMSGL of queue manager, queue and channel respectively. The maximum length of physical messages that can be handled by the entire queue manager is MAXMSGL of queue manager properties, the maximum length of physical messages that can be handled by individual queues is MAXMSGL of queue properties, and the maximum message length that can be transmitted by channels is MAXMSGL of channel properties. The default is 4MB each and can be set up to 100MB. (Possible values may vary by platform and version.) If you need to handle messages larger than these sizes, consider "Message Segmentation". MAXMSGL is generally set to be queue manager> = channel> = queue, but this is not the case if you want to segment with MAXMSGL of queue manager. It is also possible to use a combination of "logical message grouping" and "message segmentation".
In order to understand each field of MQ V2, I organize the unit of message in MQ.
group: | A group consists of one or more logical messages. The biggest concept of MQ messages. All logical messages have the same GroupId. |
Logic message: | A different MsgSeqNumber is used for each logical message in the same group. Logical messages may be divided into multiple segments. MsgSeqNumber in the group starts from 1 and exists up to the number of logical messages. |
segment: | This is a subdivision of the message to a certain size. Even if they have the same GroupId and the same MsgSeqNumber, the values set in Offset field are different for each segment. |
Physical message: | One segment is one physical message. One logical message is one physical message unless it is divided into segments. |
Fields added in MQMD V2
This section outlines the fields added in MQMD V2.
[ GroupId ]
Type: MQBYTE24
Size: 24 bytes
Initial value: MQGI_NONE_ARRAY (all NULL (0x00))
Input / output: input / output
Indicates the message group to which the message belongs. This field is also used when using message segmentation. The queue manager automatically generates an ID if MQPMO_LOGICAL_ORDER is specified on the MQPUT call. If you use MQGMO_VERSION_2 and specify GroupId together with MQMO_MATCH_GROUP_ID at the time of MQGET call, you can GET messages with specified GroupId as well as MsgId and CorrelId.
[ MsgSeqNumber ]
Type: MQLONG
Size: 4 bytes
Initial value: 1
Input / output: input / output
The number of the logical message in the message group. If MQPMO_LOGICAL_ORDER is specified on the MQPUT call, the queue manager automatically sets the appropriate sequence number. If you use MQGMO_VERSION_2 and specify MsgSeqNumber with MQMO_MATCH_MSG_SEQ_NUMBER on the MQGET call, you can GET messages with the specified MsgSeqNumber.
[ Offset ]
Type: MQLONG
Size: 4 bytes
Initial value: 0
Input / output: input / output
Indicates the offset(number of bytes) from the beginning of the logical message. When segmentation is performed in the application, if MQPMO_LOGICAL_ORDER is specified in the MQPUT call, the queue manager automatically sets the appropriate offset. If you use MQGMO_VERSION_2 and specify Offset with MQMO_MATCH_OFFSET at the time of MQGET call, you can GET messages with the specified Offset.
[ MsgFlags ]
Type: MQLONG
Size: 4 bytes
Initial value: MQMF_NONE
Input / output: input / output
It is used for the dual purpose of "Segmentation flag" that controls segment division by the queue manager, and "Status flag" that indicates the status belonging to a group and a segment of physical messages.
Each has the following flag(value).
Segmentation flag: | |
MQMF_SEGMENTATION_INHIBITED | 0x00000000 |
MQMF_SEGMENTATION_ALLOWED | 0x00000001 |
Status flag: | |
MQMF_MSG_IN_GROUP | 0x00000008 |
MQMF_LAST_MSG_IN_GROUP | 0x00000010 |
MQMF_SEGMENT | 0x00000002 |
MQMF_LAST_SEGMENT | 0x00000004 |
Set MQMF_SEGMENTATION_ALLOWED and PUT the message if you want the queue manager to allow segmentation. If you want to split the message into logical messages, set MQMF_MSG_IN_GROUP, and set MQMF_LAST_MSG_IN_GROUP for the last logical message. If you set MQMF_LAST_MSG_IN_GROUP, MQMF_MSG_IN_GROUP is automatically turned ON. When segmenting in the application, set MQMF_SEGMENT, and set MQMF_LAST_SEGMENT for the last segment. Setting MQMF_LAST_SEGMENT will automatically turn on MQMF_SEGMENT. If multiple MQMF_SEGMENTATION_ALLOWED, MQMF_ * GROUP, and MQMF_ * SEGMENT need to be set, set by their arithmetic OR.
[ OriginalLength ]
Type: MQLONG
Size: 4 bytes
Initial value: MQOL_UNDEFINED (-1)
Input / output: input / output
For report messages, indicates the length of the original message that is the subject of the report. When MQMD.MsgType is MQMT_REPORT, it is possible to specify from the application. For segments other than report messages, the length of the segment(application data) is set by the queue manager. Otherwise, the initial value MQOL_UNDEFINED(-1) is set.
This concludes the overview of each field in MQMD V2.
Message segmentation
This section describes "message segmentation".
There are two types of "Message Segmentation": "Queue Manager Segmentation" and "Application Segmentation" The receiver can also reassemble the segmented messages with the queue manager or with the application. Normally, "queue manager segmentation" is used, but problems may occur when performing character code conversion on a channel. When you transcode a message that contains multi-byte character code in the channel, it is transcoded in segment units, so character boundaries are not recognized, resulting in conversion errors or incorrect conversions occur. In this case, segmentation by the application is required. When converting code in the receiving application, you can use GET with one logical message when reassembling with the queue manager, so it is possible to convert with MQGMO_CONVERT.
Actually verify "message segmentation".
Segmentation by queue manager
The smaller of the queue manager MAXMSGL and the queue MAXMSGL to write is used for segmenting. The channel MAXMSGL is not involved in queue manager segmentation.
*If the channel tries to transfer a message larger than MAXMSGL, it fails with reason code MQRC_MSG_TOO_BIG_FOR_CHANNEL (2218).
Specify MQMF_SEGMENTATION_ALLOWED in the MQMD.MsgFlags if you want the queue manager to segment. You can specify MQMD.GroupId, but if you set MQGI_NONE, the queue manager will automatically assign a group ID. All segmented messages have the same group ID. Naturally, MQMD needs to specify (use) Version 2.
Ex. 4.1 Make the queue manager perform segmentation
Try segmenting with MAXMSGL of the queue. Set MAXMSGL for the queue to 100 to facilitate testing.
*Segment division by the queue manager may not be divided correctly by the value of MAXMSGL. For example, according to the result confirmed with MQ9.0 for Windows or MQ8.0 for HPNonStop, it is divided by the largest multiple of 8 which does not exceed MAXMSGL.
$ echo "alter ql('SampleQ') maxmsgl(100)" | runmqsc SampleQM
*Double quotes are not necessary in Windows DOS prompt and HP NonStop OSS environment.
It may be necessary for UNIX-like shells.
Prepare an arbitrary text file of 128 bytes or more.
$ ls -l largemsg.txt
-rw-r--r-- 1 MQM.MANAGER MQM 315 Apr 25 17:34 largemsg.txt
$ cat largemsg.txt
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
PUT the data of the file with specifying MQMF_SEGMENTATION_ALLOWED.
$ mqpgf -qm SampleQM -q SampleQ -f largemsg.txt MQMF_SEGMENTATION_ALLOWED MQMD_VERSION_2
[18/05/09 15:12:05] 1: put from largemsg.txt
-f: Put messages in file into a queue
MQMF_SEGMENTATION_ALLOWED: Set SEGMENTATION_ALLOWED of MQMD.MsgFlags
MQMD_VERSION_2: Set MQMD.Version to MQMD_VERSION_2
Test result 4.1
$ mqpgf -qm SampleQM -q SampleQ -dpv -r
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205AF2892120002A02] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180509] PutTime[06120565] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205AF2892120002A03] MsgSeqNumber[1] Offset[0] MsgFlags[3] OriginalLength[96]
data length: 96
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 6566 6768 696A 6B6C 'WXYZabcdefghijkl'
00000030: 6D6E 6F70 7172 7374 7576 7178 797A 0A31 'mnopqrstuvqxyz.1'
00000040: 3233 3435 3637 3839 3041 4243 4445 4647 '234567890ABCDEFG'
00000050: 4849 4A4B 4C4D 4E4F 5051 5253 5455 5657 'HIJKLMNOPQRSTUVW'
message number: 2
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205AF2892120002A04] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180509] PutTime[06120565] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205AF2892120002A03] MsgSeqNumber[1] Offset[96] MsgFlags[3] OriginalLength[96]
data length: 96
00000000: 5859 5A61 6263 6465 6667 6869 6A6B 6C6D 'XYZabcdefghijklm'
00000010: 6E6F 7071 7273 7475 7671 7879 7A0A 3132 'nopqrstuvqxyz.12'
00000020: 3334 3536 3738 3930 4142 4344 4546 4748 '34567890ABCDEFGH'
00000030: 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 'IJKLMNOPQRSTUVWX'
00000040: 595A 6162 6364 6566 6768 696A 6B6C 6D6E 'YZabcdefghijklmn'
00000050: 6F70 7172 7374 7576 7178 797A 0A31 3233 'opqrstuvqxyz.123'
message number: 3
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205AF2892120002A05] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180509] PutTime[06120565] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205AF2892120002A03] MsgSeqNumber[1] Offset[192] MsgFlags[3] OriginalLength[96]
data length: 96
00000000: 3435 3637 3839 3041 4243 4445 4647 4849 '4567890ABCDEFGHI'
00000010: 4A4B 4C4D 4E4F 5051 5253 5455 5657 5859 'JKLMNOPQRSTUVWXY'
00000020: 5A61 6263 6465 6667 6869 6A6B 6C6D 6E6F 'Zabcdefghijklmno'
00000030: 7071 7273 7475 7671 7879 7A0A 3132 3334 'pqrstuvqxyz.1234'
00000040: 3536 3738 3930 4142 4344 4546 4748 494A '567890ABCDEFGHIJ'
00000050: 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 'KLMNOPQRSTUVWXYZ'
message number: 4
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205AF2892120002A06] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180509] PutTime[06120565] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205AF2892120002A03] MsgSeqNumber[1] Offset[288] MsgFlags[7] OriginalLength[27]
data length: 27
00000000: 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 'abcdefghijklmnop'
00000010: 7172 7374 7576 7178 797A 0A 'qrstuvqxyz. '
no message available : SampleQ CompCd=02 ReasonCd=2033
It is segmented with a length of 96 bytes, which is a multiple of 8 less than 100. GroupId is automatically numbered and all have the same value. All MsgSeqNumbers are also set to "1". That is, there is one logical message. Offset starts from "0", and the value obtained by adding the divided size (96 bytes in this test) is set in the subsequent messages. MsgFlags is set to "3" except for the last segment, and the last segment is set to "7".
"3" is the OR of MQMF_SEGMENTATION_ALLOWED and MQMF_SEGMENT, and "7" is the value ORed with MQMF_LAST_SEGMENT in addition.
MQMF_SEGMENTATION_ALLOWED | 0x00000001 |
MQMF_SEGMENT | 0x00000002 |
MQMF_LAST_SEGMENT | 0x00000004 |
OriginalLength has the same value as the segmented message size.
*The value of OriginalLength has meaning when a report message is generated.
The OriginalLength set in the report message does not indicate the length of the report message itself, but the length of the original message that is the subject of the report.
When testing is complete, restore the queue settings.
$ echo "alter ql('SampleQ') maxmsgl(4194304)" | runmqsc SampleQM
Segmentation by application
mqpgf performs segmenting in an application by specifying "-as" followed by the segment size. Specifically, split the message with the specified size, specify MQMF_SEGMENT in the MsgFlags of the split segment, and MQMF_LAST_SEGMENT for the last segment. If MQPMO_LOGICAL_ORDER (described later) is not specified in the MQPMO.Options, it is necessary to set GroupId and Offset in the application. mqpgf sets Offset if MQPMO_LOGICAL_ORDER is not specified in the argument, but does not use the value automatically numbered for the first segment for GroupId for subsequent segments. If GroupId is different, MQGMO_COMPLETE_MSG (described later) or MQGMO_ALL_SEGMENTS_AVAILABLE (described later) can not be used with MQGET. To enable message reassembly, specify GroupId as an argument to mqpgf or specify MQPMO_LOGICAL_ORDER. If you manually specify GroupId with "-gi", mqpgf sets that GroupId for all segments. If the application specified MQPMO_LOGICAL_ORDER, the queue manager will automatically set the GroupId, MsgSeqNumber and Offset to appropriate values. The application only needs to specify MQMF_SEGMENT in the MsgFlags and MQMF_LAST_SEGMENT for the last segment. mqpgf also sets only MsgFlags if MQPMO_LOGICAL_ORDER is given as an argument.
Ex. 4.2 Perform segmentation in an application
Try segmenting with the application(mqpgf) specifying "-as" and MQPMO_LOGICAL_ORDER. Use the same file as above for the input message. Here, a series of messages segmented with MQPMO_SYNCPOINT is processed(Commit / Backout) inside one UOW(Unit Of Work). mqpgf automatically calls MQCMIT() if you specify MQPMO_SYNCPOINT as an argument.
*In MQ for HP NonStop, MQPMO_SYNCPOINT is not necessary because MQPMO_SYNCPOINT is the default.
$ mqpgf -qm SampleQM -q SampleQ -f largemsg.txt -as 100 MQMD_VERSION_2 MQPMO_LOGICAL_ORDER MQPMO_SYNCPOINT
[18/05/23 17:55:16] 1: put from: largemsg.txt
[18/05/23 17:55:16] 1: logical message: 1 length: 315 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.12
[18/05/23 17:55:16] 1: segment: 1 length: 100 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZa
[18/05/23 17:55:16] 1: segment: 2 length: 100 put message: bcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890A
[18/05/23 17:55:16] 1: segment: 3 length: 100 put message: BCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl
[18/05/23 17:55:16] 1: segment: 4 length: 15 put message: mnopqrstuvqxyz.
MQCMIT success : CompCd=00 ReasonCd=00
-f: Put messages in a file to a queue
-as: Split message into segments with the specified size
MQPMO_LOGICAL_ORDER: Set MQPMO_LOGICAL_ORDER of MQPMO.Options
MQMD_VERSION_2: Set MQMD.Version to MQMD_VERSION_2
The blue strings above are physical messages.
Test result 4.2
$ mqpgf -qm SampleQM -q SampleQ -dpv -r
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002A0D] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[08551656] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002A0E] MsgSeqNumber[1] Offset[0] MsgFlags[2] OriginalLength[100]
data length: 100
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 6566 6768 696A 6B6C 'WXYZabcdefghijkl'
00000030: 6D6E 6F70 7172 7374 7576 7178 797A 0A31 'mnopqrstuvqxyz.1'
00000040: 3233 3435 3637 3839 3041 4243 4445 4647 '234567890ABCDEFG'
00000050: 4849 4A4B 4C4D 4E4F 5051 5253 5455 5657 'HIJKLMNOPQRSTUVW'
00000060: 5859 5A61 'XYZa '
message number: 2
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002A0F] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[08551657] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002A0E] MsgSeqNumber[1] Offset[100] MsgFlags[2] OriginalLength[100]
data length: 100
00000000: 6263 6465 6667 6869 6A6B 6C6D 6E6F 7071 'bcdefghijklmnopq'
00000010: 7273 7475 7671 7879 7A0A 3132 3334 3536 'rstuvqxyz.123456'
00000020: 3738 3930 4142 4344 4546 4748 494A 4B4C '7890ABCDEFGHIJKL'
00000030: 4D4E 4F50 5152 5354 5556 5758 595A 6162 'MNOPQRSTUVWXYZab'
00000040: 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 'cdefghijklmnopqr'
00000050: 7374 7576 7178 797A 0A31 3233 3435 3637 'stuvqxyz.1234567'
00000060: 3839 3041 '890A '
message number: 3
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002A10] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[08551657] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002A0E] MsgSeqNumber[1] Offset[200] MsgFlags[2] OriginalLength[100]
data length: 100
00000000: 4243 4445 4647 4849 4A4B 4C4D 4E4F 5051 'BCDEFGHIJKLMNOPQ'
00000010: 5253 5455 5657 5859 5A61 6263 6465 6667 'RSTUVWXYZabcdefg'
00000020: 6869 6A6B 6C6D 6E6F 7071 7273 7475 7671 'hijklmnopqrstuvq'
00000030: 7879 7A0A 3132 3334 3536 3738 3930 4142 'xyz.1234567890AB'
00000040: 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 'CDEFGHIJKLMNOPQR'
00000050: 5354 5556 5758 595A 6162 6364 6566 6768 'STUVWXYZabcdefgh'
00000060: 696A 6B6C 'ijkl '
message number: 4
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002A11] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[08551657] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002A0E] MsgSeqNumber[1] Offset[300] MsgFlags[6] OriginalLength[15]
data length: 15
00000000: 6D6E 6F70 7172 7374 7576 7178 797A 0A 'mnopqrstuvqxyz. '
no message available : SampleQ CompCd=02 ReasonCd=2033
It is divided by the specified segment size(100)(by Application). GroupId is automatically generated and all set the same value(by Queue manager). MsgSeqNumber is also all set to "1"(by Queue Manager). Offset starts with "0" and adds the divided size to the subsequent messages(by Queue manager). MsgFlags is set to "2" except for the last segment, and the last segment is set to "6".
"2" is the value of MQMF_SEGMENT, and "6" is the value ORed with MQMF_SEGMENT and MQMF_LAST_SEGMENT. This time, MQMF_SEGMENTATION_ALLOWED is not set because it was divided by the application.
MQMF_SEGMENTATION_ALLOWED | 0x00000001 |
MQMF_SEGMENT | 0x00000002 |
MQMF_LAST_SEGMENT | 0x00000004 |
Here, mqpgf specifies only MQMF_LAST_SEGMENT in the last segment. When MQMF_LAST_SEGMENT is specified, the queue manager automatically turns on (OR) MQMF_SEGMENT and sends the message(Application + Queue Manager). OriginalLength is set to the same value as the segmented message size(Queue manager).
Reassembly of logical message by queue manager
To have the queue manager reassemble the segmented message, call MQGET() with MQGMO_COMPLETE_MSG set in the MQGMO.Options.
Ex. 4.3 Make the queue manager assemble segments
Try reassembling the segmented messages by an application with a queue manager.
Make sure the queue is empty.
$ mqpcf ques -qm SampleQM -q SampleQ CURDEPTH -t
[18/05/09 17:59:25] 1: QUEUE(SampleQ) TYPE(QUEUE) CURDEPTH(0)
PUT the message segmented into every 100 bytes by the application.
$ mqpgf -qm SampleQM -q SampleQ -f largemsg.txt -as 100 MQMD_VERSION_2 MQPMO_LOGICAL_ORDER
[18/05/23 17:57:48] 1: put from: largemsg.txt
[18/05/23 17:57:48] 1: logical message: 1 length: 315 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.12
[18/05/23 17:57:48] 1: segment: 1 length: 100 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZa
[18/05/23 17:57:48] 1: segment: 2 length: 100 put message: bcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890A
[18/05/23 17:57:48] 1: segment: 3 length: 100 put message: BCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz.1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl
[18/05/23 17:57:48] 1: segment: 4 length: 15 put message: mnopqrstuvqxyz.
$ mqpcf ques -qm SampleQM -q SampleQ CURDEPTH -t
[18/05/09 17:59:54] 1: QUEUE(SampleQ) TYPE(QUEUE) CURDEPTH(4)
It is segmented into 4 messages(CURDEPTH). (In blue )
Specify MQGMO_COMPLETE_MSG to have the queue manager reassemble segmented messages.
Test result 4.3
$ mqpgf -qm SampleQM -q SampleQ -dpv MQGMO_COMPLETE_MSG
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002B03] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[08574840] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002B04] MsgSeqNumber[1] Offset[0] MsgFlags[6] OriginalLength[315]
data length: 315
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 6566 6768 696A 6B6C 'WXYZabcdefghijkl'
00000030: 6D6E 6F70 7172 7374 7576 7178 797A 0A31 'mnopqrstuvqxyz.1'
00000040: 3233 3435 3637 3839 3041 4243 4445 4647 '234567890ABCDEFG'
00000050: 4849 4A4B 4C4D 4E4F 5051 5253 5455 5657 'HIJKLMNOPQRSTUVW'
00000060: 5859 5A61 6263 6465 6667 6869 6A6B 6C6D 'XYZabcdefghijklm'
00000070: 6E6F 7071 7273 7475 7671 7879 7A0A 3132 'nopqrstuvqxyz.12'
00000080: 3334 3536 3738 3930 4142 4344 4546 4748 '34567890ABCDEFGH'
00000090: 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 'IJKLMNOPQRSTUVWX'
000000A0: 595A 6162 6364 6566 6768 696A 6B6C 6D6E 'YZabcdefghijklmn'
000000B0: 6F70 7172 7374 7576 7178 797A 0A31 3233 'opqrstuvqxyz.123'
000000C0: 3435 3637 3839 3041 4243 4445 4647 4849 '4567890ABCDEFGHI'
000000D0: 4A4B 4C4D 4E4F 5051 5253 5455 5657 5859 'JKLMNOPQRSTUVWXY'
000000E0: 5A61 6263 6465 6667 6869 6A6B 6C6D 6E6F 'Zabcdefghijklmno'
000000F0: 7071 7273 7475 7671 7879 7A0A 3132 3334 'pqrstuvqxyz.1234'
00000100: 3536 3738 3930 4142 4344 4546 4748 494A '567890ABCDEFGHIJ'
00000110: 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 'KLMNOPQRSTUVWXYZ'
00000120: 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 'abcdefghijklmnop'
00000130: 7172 7374 7576 7178 797A 0A 'qrstuvqxyz. '
These are reassembled and retrieved as one physical message.
$ mqpcf ques -qm SampleQM -q SampleQ CURDEPTH -t
[18/05/09 18:04:18] 1: QUEUE(SampleQ) TYPE(QUEUE) CURDEPTH(0)
All four segments have been deleted in one GET.
Reassembly of logic message by application
The recommended MQGMO options for assembling logical messages in an application are:
MQGMO_SYNCPOINT, MQGMO_LOGICAL_ORDER, MQGMO_ALL_SEGMENTS_AVAILABLE
A series of segmented messages are processed (Commit / Backout) in one UOW (Unit Of Work) by specifying MQGMO_SYNCPOINT.
mqpgf automatically calls MQCMIT() if you specify MQGMO_SYNCPOINT as an argument.
*In MQ for HP NonStop, MQPMO_SYNCPOINT is not necessary because MQPMO_SYNCPOINT is the default.
Considering the case where the segments do not arrive in order due to the existence of multiple routes or the threading of the application, specify MQGMO_LOGICAL_ORDER to ensure that the segments are fetched in order.
In addition, by specifying MQGMO_ALL_SEGMENTS_AVAILABLE, MQGET() processing will not be performed until all segments have arrived in the receive queue.
Ex. 4.4 Retrieving segments in logical order
In order to see the behavior of MQGMO_LOGICAL_ORDER and MQGMO_ALL_SEGMENTS_AVAILABLE, we will try to manually queue each segment message here.
Assume a 24-byte logical message segmented into three. The size of the devided segment is 8 bytes. Since it is the same logical message, GroupId and MsgSeqNumber are the same in all segments.
Put the last (third) segment into the queue first. Specify MQMF_LAST_SEGMENT. The offset is 16.
$ mqpgf -qm SampleQM -q SampleQ -m Segment3 -gi GID -ms 1 -of 16 MQMD_VERSION_2 MQMF_LAST_SEGMENT
[18/05/23 18:01:58] 1: message length: 8 put message: Segment3
Then put the first segment into the queue. Specify MQMF_SEGMENT. Offset is 0.
$ mqpgf -qm SampleQM -q SampleQ -m Segment1 -gi GID -ms 1 -of 0 MQMD_VERSION_2 MQMF_SEGMENT
[18/05/23 18:02:12] 1: message length: 8 put message: Segment1
*Option Description
MQMD_VERSION_2: Set MQMD.Version to MQMD_VERSION_2
-gi: Set MQMD.GroupId to the specified value
-ms: Set MQMD.MsgSeqNumber to the specified value
-of: Set MQMD.Offset to the specified value
MQMF_SEGMENT: Set MQMF_SEGMENT of MQMD.MsgFlags
MQMF_LAST_SEGMENT: Set MQMF_LAST_SEGMENT of MQMD.MsgFlags
Of course there are two CURDEPTHs for the queue.
$ mqpcf ques -qm SampleQM -q SampleQ CURDEPTH
1: QUEUE(SampleQ) TYPE(QUEUE) CURDEPTH(2)
Here, try GET with MQGMO_LOGICAL_ORDER, MQGMO_ALL_SEGMENTS_AVAILABLE specified. If you specify MQGMO_LOGICAL_ORDER, you must specify MQGMO_VERSION_2 or higher and MQMD_VERSION_2. If you specify "-dp" in mqpgf, MQMD_VERSION_2 is used by default.
$ mqpgf -qm SampleQM -q SampleQ -dp -r MQGMO_VERSION_2 MQGMO_LOGICAL_ORDER MQGMO_ALL_SEGMENTS_AVAILABLE
no message available : SampleQ CompCd=02 ReasonCd=2033
$ mqrc 2033
2033 0x000007f1 MQRC_NO_MSG_AVAILABLE
Since all segments have not arrived in the receive queue, MQGET() returns MQRC_NO_MSG_AVAILABLE and no messages are received.
PUT the remaining second segment. Specify MQMF_SEGMENT. Offset is 8.
$ mqpgf -qm SampleQM -q SampleQ -m Segment2 -gi GID -ms 1 -of 8 MQMD_VERSION_2 MQMF_SEGMENT
[18/05/23 18:03:35] 1: message length: 8 put message: Segment2
As a precaution, browse the messages in the queue at this point in physical order / FIFO (default) order to confirm.
$ mqpgf -qm SampleQM -q SampleQ -br -r
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C09] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09015893] ApplOriginData[ ]
GroupId[0x474944000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[16] MsgFlags[6] OriginalLength[8]
data length: 8
00000000: 5365 676D 656E 7433 'Segment3 '
message number: 2
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C0B] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09021276] ApplOriginData[ ]
GroupId[0x474944000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[2] OriginalLength[8]
data length: 8
00000000: 5365 676D 656E 7431 'Segment1 '
message number: 3
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C11] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09033505] ApplOriginData[ ]
GroupId[0x474944000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[8] MsgFlags[2] OriginalLength[8]
data length: 8
00000000: 5365 676D 656E 7432 'Segment2 '
no message available : SampleQ CompCd=02 ReasonCd=2033
The segments are arranged in the order of 3rd, 1st, 2nd.
Try repeatedly GET specifying MQGMO_LOGICAL_ORDER, MQGMO_ALL_SEGMENTS_AVAILABLE.
Test result 4.4
$ mqpgf -qm SampleQM -q SampleQ -dp -r MQGMO_VERSION_2 MQGMO_LOGICAL_ORDER MQGMO_ALL_SEGMENTS_AVAILABLE MQGMO_SYNCPOINT
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C0B] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09021276] ApplOriginData[ ]
GroupId[0x474944000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[2] OriginalLength[8]
data length: 8
00000000: 5365 676D 656E 7431 'Segment1 '
message number: 2
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C11] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09033505] ApplOriginData[ ]
GroupId[0x474944000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[8] MsgFlags[2] OriginalLength[8]
data length: 8
00000000: 5365 676D 656E 7432 'Segment2 '
message number: 3
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C09] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09015893] ApplOriginData[ ]
GroupId[0x474944000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[16] MsgFlags[6] OriginalLength[8]
data length: 8
00000000: 5365 676D 656E 7433 'Segment3 '
no message available : SampleQ CompCd=02 ReasonCd=2033
MQCMIT success : CompCd=00 ReasonCd=00
*Option Description
-dp: GET the message and dump in the same format as "-br".
-r: Repeatedly GET the message on the queue
MQGMO_VERSION_2: Set MQGMO.Version to MQGMO_VERSION_2
MQGMO_LOGICAL_ORDER: Set MQGMO_LOGICAL_ORDER of MQGMO.Options
MQGMO_ALL_SEGMENTS_AVAILABLE: Set MQGMO_ALL_SEGMENTS_AVAILABLE of MQGMO.Options.
MQGMO_SYNCPOINT: Set MQGMO_SYNCPOINT of MQGMO.Options
The segments are properly received in logical order according to the Offset value.
*mqpgf does not reassemble the actual logical message. You can check that the segments can be received in the intended order.
Grouping of logical messages
Grouping of logical messages
Grouping of logical messages can not be done automatically by the queue manager like message segmentation. Following "-dl" option, mqpgf can specify a delimiter to be used to create a logical message grouped from the specified message or file. Specifically, the message is divided into logical messages excluding delimiters, and MQMF_MSG_IN_GROUP is specified in the MsgFlags of the divided logical message, and MQMF_LAST_MSG_IN_GROUP is specified for the last logical message. MQPMO_LOGICAL_ORDER also works with logical message grouping. If MQPMO_LOGICAL_ORDER is not specified in the MQPMO.Options, it is necessary to set GroupId and MsgSeqNumber by the application. If MQPMO_LOGICAL_ORDER is not specified in the argument and GroupId is not specified, different GroupId will be assigned to each logical message, and MsgSeqNumber will not be incremented. If the application specified MQPMO_LOGICAL_ORDER, the queue manager will automatically set the GroupId, MsgSeqNumber (and Offset) to appropriate values. In that case, the application only needs to specify MQMF_MSG_IN_GROUP in the MsgFlags and MQMF_LAST_MSG_IN_GROUP for the last logical message. Also, although segment reassembly could be performed by the queue manager by specifying MQGMO_COMPLETE_MSG, reassembly from logical messages can not be performed by the queue manager.
Ex. 4.5 Generating grouped logical messages
Prepare a multi-line arbitrary text file as shown below.
$ cat largemsg2.txt
1234567890
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
Specify this multi-line file (line feed: LF: 0x0a) as a delimiter of 0x0a (LF), divide it into logical messages for each line, and try to PUT the message. Also specify MQPMO_LOGICAL_ORDER.
*In case of Windows, line feed is usually 0x0d0a (CRLF), so please specify like "-dl 0x0d0a".
The line break is 0x0a (LF) in the Unix OS and the HP NonStop OSS environment.
$ mqpgf -qm SampleQM -q SampleQ -f largemsg2.txt -dl 0x0a MQMD_VERSION_2 MQPMO_LOGICAL_ORDER MQPMO_SYNCPOINT
[18/05/23 18:05:31] 1: put from: largemsg2.txt
[18/05/23 18:05:31] 1: logical message: 1 length: 10 put message: 1234567890
[18/05/23 18:05:31] 1: logical message: 2 length: 62 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
[18/05/23 18:05:31] 1: logical message: 3 length: 62 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
[18/05/23 18:05:31] 1: logical message: 4 length: 36 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
[18/05/23 18:05:31] 1: logical message: 5 length: 62 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
MQCMIT success : CompCd=00 ReasonCd=00
*Option description
-f: Put messages in the file into a queue
-dl: Specify delimiter as a string or hexadecimal notation
MQGMO_VERSION_2:Set MQGMO.Version to MQGMO_VERSION_2
MQPMO_LOGICAL_ORDER: Set MQPMO_LOGICAL_ORDER of MQPMO.Options
MQPMO_SYNCPOINT: Set MQGMO_SYNCPOINT of MQPMO.Options
The portion in blue is the physical message.
Check the split messages. In this case, a logical messages is a physical messages.
Test result 4.5
$ mqpgf -qm SampleQM -q SampleQ -dp -r
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C18] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09053189] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002C19] MsgSeqNumber[1] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 10
00000000: 3132 3334 3536 3738 3930 '1234567890 '
message number: 2
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C1A] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09053190] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002C19] MsgSeqNumber[2] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 62
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 6566 6768 696A 6B6C 'WXYZabcdefghijkl'
00000030: 6D6E 6F70 7172 7374 7576 7178 797A 'mnopqrstuvqxyz '
message number: 3
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C1B] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09053190] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002C19] MsgSeqNumber[3] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 62
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 6566 6768 696A 6B6C 'WXYZabcdefghijkl'
00000030: 6D6E 6F70 7172 7374 7576 7178 797A 'mnopqrstuvqxyz '
message number: 4
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C1C] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09053190] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002C19] MsgSeqNumber[4] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 36
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 'WXYZ '
message number: 5
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B05070120002C1D] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180523] PutTime[09053190] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B05070120002C19] MsgSeqNumber[5] Offset[0] MsgFlags[24] OriginalLength[-1]
data length: 62
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 6566 6768 696A 6B6C 'WXYZabcdefghijkl'
00000030: 6D6E 6F70 7172 7374 7576 7178 797A 'mnopqrstuvqxyz '
no message available : SampleQ CompCd=02 ReasonCd=2033
It is divided into logical messages line by line (LF: 0x0a)(Application). GroupId is automatically generated and all have the same value(Queue manager). MsgSeqNumber is also incremented sequentially from "1"(Queue manager). MsgFlags is set to "8" except for the last segment, and the last segment is set to "24".
"3" is the value of MQMF_MSG_IN_GROUP, and "24" is the value obtained by ORing MQMF_MSG_IN_GROUP and MQMF_LAST_MSG_IN_GROUP.
MQMF_MSG_IN_GROUP | 0x00000008 |
MQMF_LAST_MSG_IN_GROUP | 0x00000010 |
※MQMF_MSG_IN_GROUP | MQMF_LAST_MSG_IN_GROUP = 0x00000008 | 0x00000010 = 0x00000018(Hexadecimal) = 24(Decimal)
mqpgf specifies only MQMF_MSG_IN_GROUP in the last segment. If MQMF_LAST_MSG_IN_GROUP is specified, the queue manager automatically turns on (OR) MQMF_MSG_IN_GROUP and sends the message(Application + Queue Manager).
Grouping of logical messages and logical message segmentation
It is also possible to combine logical message grouping with logical message segmentation.
Ex. 4.6 Combining grouping and segmentation
Use the same file as before and add "-as 40" as an argument and try to segment the logical message exceeding 40 bytes by application.
$ mqpgf -qm SampleQM -q SampleQ -f largemsg2.txt -dl 0x0a -as 40 MQMD_VERSION_2 MQPMO_LOGICAL_ORDER MQPMO_SYNCPOINT
[18/05/25 15:12:29] 1: put from: largemsg2.txt
[18/05/25 15:12:29] 1: logical message: 1 length: 10 put message: 1234567890
[18/05/25 15:12:29] 1: logical message: 2 length: 62 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
[18/05/25 15:12:29] 1: segment: 1 length: 40 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcd
[18/05/25 15:12:29] 1: segment: 2 length: 22 put message: efghijklmnopqrstuvqxyz
[18/05/25 15:12:29] 1: logical message: 3 length: 62 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
[18/05/25 15:12:29] 1: segment: 1 length: 40 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcd
[18/05/25 15:12:29] 1: segment: 2 length: 22 put message: efghijklmnopqrstuvqxyz
[18/05/25 15:12:29] 1: logical message: 4 length: 36 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
[18/05/25 15:12:29] 1: logical message: 5 length: 62 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvqxyz
[18/05/25 15:12:29] 1: segment: 1 length: 40 put message: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcd
[18/05/25 15:12:29] 1: segment: 2 length: 22 put message: efghijklmnopqrstuvqxyz
MQCMIT success : CompCd=00 ReasonCd=00
*Option description
-f: Put messages in the file into a queue
-dl: Specify delimiters in a string or hexadecimal notation to divide into logical messages
-as: Divide a message into segments with a specified size
MQMD_VERSION_2: Set MQMD.Version to MQMD_VERSION_2
MQPMO_LOGICAL_ORDER: Set MQPMO_LOGICAL_ORDER of MQPMO.Options
MQPMO_SYNCPOINT: Set MQGMO_SYNCPOINT of MQPMO.Options
The portion in blue is the physical message.。
Check the split messages.
Test result 4.6
$ mqpgf -qm SampleQM -q SampleQ -dp -r
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002302] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122950] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[1] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 10
00000000: 3132 3334 3536 3738 3930 '1234567890 '
message number: 2
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002304] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122951] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[2] Offset[0] MsgFlags[10] OriginalLength[40]
data length: 40
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 'WXYZabcd '
message number: 3
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002305] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122951] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[2] Offset[40] MsgFlags[14] OriginalLength[22]
data length: 22
00000000: 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 'efghijklmnopqrst'
00000010: 7576 7178 797A 'uvqxyz '
message number: 4
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002306] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122951] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[3] Offset[0] MsgFlags[10] OriginalLength[40]
data length: 40
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 'WXYZabcd '
message number: 5
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002307] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122951] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[3] Offset[40] MsgFlags[14] OriginalLength[22]
data length: 22
00000000: 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 'efghijklmnopqrst'
00000010: 7576 7178 797A 'uvqxyz '
message number: 6
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002308] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122952] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[4] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 36
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 'WXYZ '
message number: 7
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002309] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122952] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[5] Offset[0] MsgFlags[26] OriginalLength[40]
data length: 40
00000000: 3132 3334 3536 3738 3930 4142 4344 4546 '1234567890ABCDEF'
00000010: 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 'GHIJKLMNOPQRSTUV'
00000020: 5758 595A 6162 6364 'WXYZabcd '
message number: 8
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F82000230A] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[06122952] ApplOriginData[ ]
GroupId[0x414D512053616D706C65514D202020205B07A8F820002303] MsgSeqNumber[5] Offset[40] MsgFlags[30] OriginalLength[22]
data length: 22
00000000: 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 'efghijklmnopqrst'
00000010: 7576 7178 797A 'uvqxyz '
no message available : SampleQ CompCd=02 ReasonCd=2033
MQCMIT success : CompCd=00 ReasonCd=00
You can see that Offset is set for the physical message of the 2nd, 3rd, and 5th logical messages (MsgSeqNumber is 2, 3, 5) and the segment is divided into multiple segments.
Retrieving group messages
Specify MQGMO_COMPLETE_MSG to have the queue manager reassemble logical messages from the segment. Specifying MQGMO_LOGICAL_ORDER allows logical messages to be read out in order. Specify MQGMO_ALL_MSGS_AVAILABLE to ensure that processing starts only after all the messages in the group have arrived. Specify MQGMO_ALL_SEGMENTS_AVAILABLE to prevent processing of segments until all segments of the logical message have arrived.
Ex. 4.7 Retrieving group messages in logical order
Try to manually queue each physical message one by one to make it easier to understand the behavior of each option.
Assume two types of group messages divided as follows.
group 1 logical message 1 segment 1
group 1 logical message 1 segment 2
group 1 logical message 2
group 1 logical message 3 segment 1
group 1 logical message 3 segment 2
group 2 logical message 1
group 2 logical message 2 segment 1
group 2 logical message 2 Segment 2
These corresponding command lines are:
mqpgf -qm SampleQM -q SampleQ -m Group1Logical1Segment1 -gi GroupId1 -ms 1 -of 0 MQMD_VERSION_2 MQMF_SEGMENT MQMF_MSG_IN_GROUP
mqpgf -qm SampleQM -q SampleQ -m Group1Logical1Segment2 -gi GroupId1 -ms 1 -of 22 MQMD_VERSION_2 MQMF_LAST_SEGMENT MQMF_MSG_IN_GROUP
mqpgf -qm SampleQM -q SampleQ -m Group1Logical2 -gi GroupId1 -ms 2 MQMD_VERSION_2 MQMF_MSG_IN_GROUP
mqpgf -qm SampleQM -q SampleQ -m Group1Logical3Segment1 -gi GroupId1 -ms 3 -of 0 MQMD_VERSION_2 MQMF_SEGMENT MQMF_LAST_MSG_IN_GROUP
mqpgf -qm SampleQM -q SampleQ -m Group1Logical3Segment2 -gi GroupId1 -ms 3 -of 22 MQMD_VERSION_2 MQMF_LAST_SEGMENT MQMF_LAST_MSG_IN_GROUP
mqpgf -qm SampleQM -q SampleQ -m Group2Logical1 -gi GroupId2 -ms 1 MQMD_VERSION_2 MQMF_MSG_IN_GROUP
mqpgf -qm SampleQM -q SampleQ -m Group2Logical2Segment1 -gi GroupId2 -ms 2 -of 0 MQMD_VERSION_2 MQMF_SEGMENT MQMF_LAST_MSG_IN_GROUP
mqpgf -qm SampleQM -q SampleQ -m Group2Logical2Segment2 -gi GroupId2 -ms 2 -of 22 MQMD_VERSION_2 MQMF_LAST_SEGMENT MQMF_LAST_MSG_IN_GROUP
*Option Description
-gi: Set MQMD.GroupId to the specified value
-ms: Set MQMD.MsgSeqNumber to the specified value
-of: Set MQMD.Offset to the specified value
MQMD_VERSION_2: Set MQMD.Version to MQMD_VERSION_2
MQMF_SEGMENT: Set MQMF_SEGMENT of MQMD.MsgFlags
MQMF_MSG_IN_GROUP: Set MQMF_MSG_IN_GROUP of MQMD.MsgFlags
MQMF_LAST_SEGMENT: Set MQMF_LAST_SEGMENT of MQMD.MsgFlags
MQMF_LAST_MSG_IN_GROUP: Set MQMF_LAST_MSG_IN_GROUP of MQMD.MsgFlags
First, start mqpgf for reception with the following arguments at another terminal / command prompt.
$ mqpgf -qm SampleQM -q SampleQ -dp -r MQGMO_VERSION_2 MQGMO_COMPLETE_MSG MQGMO_LOGICAL_ORDER MQGMO_ALL_MSGS_AVAILABLE MQGMO_ALL_SEGMENTS_AVAILABLE MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT
*Option descriptions
MQMD_VERSION_2: Set MQMD.Version to MQMD_VERSION_2
MQGMO_COMPLETE_MSG: Set MQGMO_COMPLETE_MSG of MQGMO.Options
MQGMO_LOGICAL_ORDER: Set MQGMO_LOGICAL_ORDER of MQGMO.Options
MQGMO_ALL_MSGS_AVAILABLE: Set MQGMO_ALL_MSGS_AVAILABLE of MQGMO.Options
MQGMO_ALL_SEGMENTS_AVAILABLE: Set MQGMO_ALL_SEGMENTS_AVAILABLE of MQGMO.Options
MQGMO_WAIT: Set MQGMO_WAIT of MQGMO.Options
MQWI_UNLIMITED: Set MQGMO.WaitInterval to MQWI_UNLIMITED
MQGMO_NO_SYNCPOINT: Set MQGMO_NO_SYNCPOINT of MQGMO.Options
By specifying MQGMO_WAIT and MQWI_UNLIMITED, it waits indefinitely for all messages in the group to reach the queue. Processing of messages for each group should begin when they all arrive. In addition, it is repeated in multiple groups by specifying the "-r" option.
Then, put messages in random order.
$ mqpgf -qm SampleQM -q SampleQ -m Group2Logical2Segment2 -gi GroupId2 -ms 2 -of 22 MQMD_VERSION_2 MQMF_LAST_SEGMENT MQMF_LAST_MSG_IN_GROUP
[18/05/25 16:45:38] 1: message length: 22 put message : Group2Logical2Segment2
$ mqpgf -qm SampleQM -q SampleQ -m Group1Logical3Segment2 -gi GroupId1 -ms 3 -of 22 MQMD_VERSION_2 MQMF_LAST_SEGMENT MQMF_LAST_MSG_IN_GROUP
[18/05/25 16:45:44] 1: message length: 22 put message : Group1Logical3Segment2
$ mqpgf -qm SampleQM -q SampleQ -m Group2Logical2Segment1 -gi GroupId2 -ms 2 -of 0 MQMD_VERSION_2 MQMF_SEGMENT MQMF_LAST_MSG_IN_GROUP
[18/05/25 16:45:49] 1: message length: 22 put message : Group2Logical2Segment1
$ mqpgf -qm SampleQM -q SampleQ -m Group1Logical3Segment1 -gi GroupId1 -ms 3 -of 0 MQMD_VERSION_2 MQMF_SEGMENT MQMF_LAST_MSG_IN_GROUP
[18/05/25 16:45:55] 1: message length: 22 put message : Group1Logical3Segment1
$ mqpgf -qm SampleQM -q SampleQ -m Group1Logical2 -gi GroupId1 -ms 2 MQMD_VERSION_2 MQMF_MSG_IN_GROUP
[18/05/25 16:46:01] 1: message length: 14 put message : Group1Logical2
$ mqpgf -qm SampleQM -q SampleQ -m Group1Logical1Segment2 -gi GroupId1 -ms 1 -of 22 MQMD_VERSION_2 MQMF_LAST_SEGMENT MQMF_MSG_IN_GROUP
[18/05/25 16:46:06] 1: message length: 22 put message : Group1Logical1Segment2
$ mqpgf -qm SampleQM -q SampleQ -m Group2Logical1 -gi GroupId2 -ms 1 MQMD_VERSION_2 MQMF_MSG_IN_GROUP
[18/05/25 16:46:11] 1: message length: 14 put message : Group2Logical1
At this point we have written all group 2 messages so the mqpgf that was waiting for MQGET() on the other terminal should have processed the messages and made them visible.
Test result 4.7.1
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002F0C] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[08070964] ApplOriginData[ ]
GroupId[0x47726F757049643200000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 14
00000000: 4772 6F75 7032 4C6F 6769 6361 6C31 'Group2Logical1 '
message number: 2
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002F04] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[08065027] ApplOriginData[ ]
GroupId[0x47726F757049643200000000000000000000000000000000] MsgSeqNumber[2] Offset[0] MsgFlags[30] OriginalLength[44]
data length: 44
00000000: 4772 6F75 7032 4C6F 6769 6361 6C32 5365 'Group2Logical2Se'
00000010: 676D 656E 7431 4772 6F75 7032 4C6F 6769 'gment1Group2Logi'
00000020: 6361 6C32 5365 676D 656E 7432 'cal2Segment2 '
You can get the logical message in the order of the logical message, and you can confirm that the divided segments become one logical message.
Finally write the remaining 1 messages of group 1
$ mqpgf -qm SampleQM -q SampleQ -m Group1Logical1Segment1 -gi GroupId1 -ms 1 -of 0 MQMD_VERSION_2 MQMF_SEGMENT MQMF_MSG_IN_GROUP
[18/05/25 16:46:16] 1: message length: 22 put message : Group1Logical1Segment1
At this point, since all messages in group 1 have been written, mqpgf, which was waiting for MQGET() in the other terminal, processes the messages and displays them.
Test result 4.7.2
message number: 3
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002F0E] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[08074051] ApplOriginData[ ]
GroupId[0x47726F757049643100000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[14] OriginalLength[44]
data length: 44
00000000: 4772 6F75 7031 4C6F 6769 6361 6C31 5365 'Group1Logical1Se'
00000010: 676D 656E 7431 4772 6F75 7031 4C6F 6769 'gment1Group1Logi'
00000020: 6361 6C31 5365 676D 656E 7432 'cal1Segment2 '
message number: 4
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002F08] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[08065979] ApplOriginData[ ]
GroupId[0x47726F757049643100000000000000000000000000000000] MsgSeqNumber[2] Offset[0] MsgFlags[8] OriginalLength[-1]
data length: 14
00000000: 4772 6F75 7031 4C6F 6769 6361 6C32 'Group1Logical2 '
message number: 5
*StrucId[MD ] Version[2] Report[0] MsgType[8] Expiry[-1] Feedback[0] Encoding[273] CodedCharSetId[943] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020205B07A8F820002F06] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x0534343033310000000000000000000000000000000000000000000000000006] ApplIdentityData[ ] PutApplType[13] PutApplName[mqpgf ] PutDate[20180525] PutTime[08065488] ApplOriginData[ ]
GroupId[0x47726F757049643100000000000000000000000000000000] MsgSeqNumber[3] Offset[0] MsgFlags[30] OriginalLength[44]
data length: 44
00000000: 4772 6F75 7031 4C6F 6769 6361 6C33 5365 'Group1Logical3Se'
00000010: 676D 656E 7431 4772 6F75 7031 4C6F 6769 'gment1Group1Logi'
00000020: 6361 6C33 5365 676D 656E 7432 'cal3Segment2 '
*The messages in group 1 are also received in the order of logical messages, and it can be confirmed that the divided segments are one logical message. In this example, we have divided the data of one file into a grouped logical message, but mqpgf does not reassemble it into one message or file when reading them. You can only confirm that the logical messages are received in the intended order.
In the next chapter, I will continue to explain the fields added in MQMD Version 2.