Japanese

Practical mastering IBM MQ basics

Message descriptor (MQMD) (3)

*This series may be revised based on the latest mqpgf/mqpcf. Please always download and use the latest version.

[ MsgId ]

Type: MQBYTE24
Size: 24 bytes
Initial value: MQMI_NONE (all NULL (0x00))
Input / output: input / output

This is the ID that uniquely identifies MQ messages. If you specified MQMI_NONE or MQPMO_NEW_MSG_ID when calling MQPUT(), the queue manager generates a unique ID and sets it in the message. MQMI_NONE is the default, so a unique message ID is generated each time unless otherwise specified. At this time, the ID is created from the 4-byte product ID, the first 12 characters of the queue manager name, and the value based on the system clock. This is one reason why you need to make queue manager names unique within an MQ network. Note that duplication of MsgId may occur if the system clock is changed in the reverse direction, including when the system clock is manually changed during operation. Also, there are cases where system created strings are used, but since this field is a binary field, note that conversion of character code between platforms with different character code is not performed.
If this value is specified at MQGET(), only messages with a specific MsgId can be read.

[ CorrelId ]

Type: MQBYTE24
Size: 24 bytes
Initial value: MQCI_NONE (all NULL (0x00))
Input / Output: MQGET(): I/O, MQPUT(): MQPMO_NEW_CORREL_ID Specified: input, unspecified: output

The queue manager generates a unique ID only when MQPMO_NEW_CORREL_ID is specified.
The ID generation rule is the same as MsgId.
By specifying this value at MQGET(), you can read only messages with a specific CorrelId.
It is used for associating messages or processing, but the most common usage is to associate request messages with their response messages. (Described later)

The following is an example of PUT / GET specifying MsgId and CorrelId in hexadecimal notation.
*If you use MQGMO_VERSION_2, you can use MatchOption (MQMO_ *), but the default is MQGMO_VERSION_1, so this option is not available by default. More on this later.


Ex. 3.1 GET a specific message

Three messages are written. The last one digits of these MsgIds are all different, the CorrelId is the same for the first two messages.
*The values specified for -mi and -ci must be 24 bytes or less (24 * 2 = 48 characters or less and an even number, excluding "0x" in hexadecimal notation). If specified within 24 bytes, mqpgf fills the trail with NULL(0x00).

$ mqpgf -qm SampleQM -q SampleQ -m "MsgId CorrelId Test1" -mi 0x414D512053616D706C65514D202020205ABC2DC820008811 -ci 0x414D512053616D706C65514D202020205ABC2DC82000881A
[18/04/09 11:50:06] 1: message length: 20 put message : MsgId CorrelId Test1

$ mqpgf -qm SampleQM -q SampleQ -m "MsgId CorrelId Test2" -mi 0x414D512053616D706C65514D202020205ABC2DC820008812 -ci 0x414D512053616D706C65514D202020205ABC2DC82000881A
[18/04/09 11:50:17] 1: message length: 20 put message : MsgId CorrelId Test2

$ mqpgf -qm SampleQM -q SampleQ -m "MsgId CorrelId Test3" -mi 0x414D512053616D706C65514D202020205ABC2DC820008813 -ci 0x414D512053616D706C65514D202020205ABC2DC82000881B
[18/04/09 11:50:21] 1: message length: 20 put message : MsgId CorrelId Test3

*Option descriptions
-mi: Specify MQMD.MsgId (If specifying in hexadecimal notation, add "0x" at the beginning)
-ci: Specify MQMD.CorrelId (If specifying in hexadecimal notation, add "0x" at the beginning)

Here are examples of GET with some patterns. Please try it in various ways.

Test result 3.1

If you specify both MsgId and CorrelId for GET, both must match.

$ mqpgf -qm SampleQM -q SampleQ -br -mi 0x414D512053616D706C65514D202020205ABC2DC820008812 -ci 0x414D512053616D706C65514D202020205ABC2DC82000881A
message number: 1
*StrucId[MD ] .... MsgId[0x414D512053616D706C65514D202020205ABC2DC820008812] CorrelId[0x414D512053616D706C65514D202020205ABC2DC82000881A] ....
....
00000000: 4D73 6749 6420 436F 7272 656C 4964 2054 'MsgId CorrelId T'
00000010: 6573 7432 'est2

Specify CorrelId and try to GET by specifying repeat option ("-r"). Two messages match.

$ mqpgf -qm SampleQM -q SampleQ -br -r -ci 0x414D512053616D706C65514D202020205ABC2DC82000881A
message number: 1
*StrucId[MD ] .... MsgId[0x414D512053616D706C65514D202020205ABC2DC820008811] CorrelId[0x414D512053616D706C65514D202020205ABC2DC82000881A] ....
....
data length: 20
00000000: 4D73 6749 6420 436F 7272 656C 4964 2054 'MsgId CorrelId T'
00000010: 6573 7431 'est1 '

message number: 2
*StrucId[MD ] .... MsgId[0x414D512053616D706C65514D202020205ABC2DC820008812] CorrelId[0x414D512053616D706C65514D202020205ABC2DC82000881A] ....
....
data length: 20
00000000: 4D73 6749 6420 436F 7272 656C 4964 2054 'MsgId CorrelId T'
00000010: 6573 7432 'est2 '

fig 3.1

[ BackoutCount ]

Type: MQLONG
Size: 4 bytes
Initial value: 0
Input / output: output

The number of times the message has been backed out is set. MQGMO_SYNCPOINT is specified and MQGET() is called within a unit of work, it will be counted up when the application calls MQBACK() or the application terminates abnormally before MQCMIT() is called. When MQGMO_SYNCPOINT is specified, MQGET() called within a unit of work is not committed until MQCMIT() is invoked. Note that the default for Windows, Linux, UNIX is MQGMO_NO_SYNCPOINT, and MQPUT() / MQGET() is not called within a unit of work, but for MQ for HP NonStop, the default is MQGMO_SYNCPOINT. Also, if the MQGET() call itself fails and the message GET can not be performed, it is not counted up.
The HardenGetBackout queue attribute, which affects count accuracy, is valid only on z/OS and not on distributed platforms and HP NonStop.


Ex. 3.2 Backing out messages

Test with some patterns. PUT 15K messages.

$ mqpgf -qm SampleQM -q SampleQ -m "backout test" -l 15000
[18/04/09 16:04:49] 1: message length: 15000 put message : backout test....................................................................................................................

*Option descriptions
-l: Size of message to put. If it is smaller than the specified message length, the remainder is discarded, and if it is larger, NULL(0x00) is added for the specified size.


Test result 3.2

The default receive buffer size for mqpgf is 12K, so the MQGET() call fails with reason code 2080: MQRC_TRUNCATED_MSG_FAILED unless the receive buffer size is extended with "-sz". At this time, BackoutCount does not count up.

$ mqpgf -qm SampleQM -q SampleQ MQGMO_SYNCPOINT
MQGET with warning : SampleQ CompCd=01 ReasonCd=2080 len=15000
MQBACK success : CompCd=00 ReasonCd=00

$ mqpgf -qm SampleQM -q SampleQ -br -sz 15000
message number: 1
*StrucId[MD ] .... BackoutCount[0] .... *In this case, it is not counted up.
....

mqpgf automatically calls MQCMIT() when MQGMO_SYNCPOINT or MQPMO_SYNCPOINT is specified. If an error occurs, call MQBACK(). If "-b" is specified, even if the process is normal, MQBACK() can be called to forcibly back out, without calling MQCMIT().

$ mqpgf -qm SampleQM -q SampleQ MQGMO_SYNCPOINT -sz 15000 -b
[18/04/09 16:38:08] 1: message length: 15000 get message : backout test....................................................................................................................
MQBACK success : CompCd=00 ReasonCd=00

$ mqpgf -qm SampleQM -q SampleQ -br -sz 15000
message number: 1
*StrucId[MD ] .... BackoutCount[1] ....
....

Specifying any MQ API(MQI) name called after the "-s" option will stop processing before that API is called. (The following process is continued with any key input.) Specify "MQCMIT" after "-s" to stop the process after MQGET() succeeds and before calling MQCMIT() and kill the process. For Windows, expand "Windows Command Processor" from Task Manager, select "mqpgf.exe (32 bit)" and select "End Task". (In MQ for Windows, Ctrl-C does not force the process to terminate, but commits the process.) For Unix-like OS and HP NonStop OSS, kill the process with kill command or CTL-C.

$ mqpgf -qm SampleQM -q SampleQ MQGMO_SYNCPOINT -sz 15000 -s MQCMIT
[18/04/09 16:42:52] 1: message length: 15000 get message : backout test....................................................................................................................
stop before calling MQCMIT().
Hit Any Key!!!
*Forced termination here

Here, it takes a certain time for the queue manager to detect abnormal termination of the application and back out the message. Please wait for about 10 seconds.
*This time is different depending on the platform, and the result of the test here is especially confirmed by the verification with MQ 9.0 for Linux. Windows and HP NonStop did not see noticeable delays.
$ mqpgf -qm SampleQM -q SampleQ -br -sz 15000
message number: 1
*StrucId[MD ] .... BackoutCount[2] ....
....

*Option descriptions
MQGMO_SYNCPOINT: Set MQGMO_SYNCPOINT of MQGMO.Options
-sz: Size of receive buffer
-b: Forced backout
-s: Stop before calling specified MQI

fig 3.2

[ ReplyToQ ]

Type: MQCHAR48
Size: 48 bytes
Initial value: NULL string (C language)
Input / output: MQGET(): Output, MQPUT(): Input

This is the destination queue for sending the report message (MQMT_REPORT) and reply message (MQMT_REPLY) described in the Report and MsgType fields mentioned previously. Test Result 1.3.1, Test Result 1.3.2, and Test Result 2.2 have already confirmed that MQMD.ReplyToQ and MQMD.RepyToQMgr are used as the destination of the report message.

[ ReplyToQMgr ]

Type: MQCHAR48
Size: 48 bytes
Initial value: NULL string (C language)
Input / output: MQGET(): Output, MQPUT(): Input

This is the destination queue manager name for sending the report message and reply message. As related information, I mentioned a little on the description for Report field, but when sending a message to the remote queue manager, a transmission queue is selected in the following order:

  1. 1. The transmission queue specified XMITQ property of the locally definition of the remote queue
  2. 2. A transmission queue with the same name as the remote queue manager
  3. 3. Transmission queue specified in the queue manager DEFXMITQ property
Therefore, when the queue manager automatically generates and sends a report message, it is not always necessary to define the remote queue locally. Also, if you create a transmission queue name with the same name as the remote queue manager, you do not need to specify the XMITQ parameter for the remote queue's local definition.

In this test, a request message is sent from SampleQM to RemoteQM, and the response message is sent from RemoteQM by the application(mqpgf). Therefore, on the RemoteQM side, create a local definition for SampleQ, which is the remote queue viewed from RemoteQM, which is the response reception queue for SampleQM.

mqpcf mqsc -qm RemoteQM -s "def qr('SampleQ') rname('SampleQ') rqmname('SampleQM')"
1: AMQ8006: IBM MQ queue created.

*Option descriptions
mqsc: MQSC command execution
-s : MQSC command string

Now, after sending the request message, test the reception of the reply message returned to ReplyToQ / ReplyToQMgr.
At this time, only messages with the same CorrelId as MsgId sent will be received. In this test, mqpgf is started by the following options on the request side and the response side. Describes each options.

Request transmission / response reception command started on SampleQM side:
$ mqpgf -qm SampleQM -q RemoteQ -m "request reply test" -iq SampleQ -rm SampleQM -rq SampleQ MQMT_REQUEST MQPMO_NO_SYNCPOINT -n 3 -i 1000 -ss MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT -dp -mc

*Option descriptions
-iq: input queue name
-rm: Set Specify the value to be set for MQMD.ReplyToQMgr
-rq: Specify the value to be set for MQMD.ReplyToQ
MQMT_REQUEST: Set MQMD.MsgType to MQMT_REQUEST
MQPMO_NO_SYNCPOINT:Set MQPMO_NO_SYNCPOINT of MQPMO.Options
-n: Specify the number of times to put / get.
-i: Specify the repeat interval of put / get in ms.
-ss: Switches subsequent options / parameters to the input side (secondary side).
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
-dp: GET the message and dump the message in the same format as "-br".
-mc: Receive a message with the same CorrelId as MsgId of the sent message.


Describes the details of the option.
 Specify the queue name to receive the response with "-iq".
 Specify the queue manager name to be set to MQMD.ReplyToQMgr with "-rm". If not specified, the default is the local queue manager name, so it can be omitted. MQMD.ReplyToQMgr is set to MQOD.ObjectQMgrName.
 Specify the queue name to be set to MQMD.ReplyToQ with "-rq".
 MQMT_REQUEST is set to MQMD.MsgType for outgoing messages.
 MQPMO_NO_SYNCPOINT prevents MQPUT() from being called within a unit of work.
 "-ss" is used with "-iq", "-oq", and the subsequent options / parameters are switched the queue (secondary side) specified with "-iq", "-oq" instead of the queue specified with "-q" (primary side).
 If you specify MQGMO_WAIT, MQGET() waits for a message to arrive.
 MQWI_UNLIMITED makes the wait time in MQGMO_WAIT indefinitely.
 MQGMO_NO_SYNCPOINT prevents MQGET() from being called within a unit of work.
 "-dp" is the same as "-br" except that the browse option is not specified (the message is deleted from the queue after reading the message).
 If you specify "-mc", only messages with the same CorrelId as MsgId of the sent message will be waited. This links the request to the response.

Request reception / response transmission command activated on RemoteQM side:
$ mqpgf -qm RemoteQM -q RemoteQ -oq "*" MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT -dp -n 3 -ss MQMT_REPLY MQPMO_NO_SYNCPOINT -im

*Option descriptions
-oq: output queue name
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
-dp: GET the message and dump the message in the same format as "-br".
-n: Execute PUT / GET processing a specified number of times.
-ss: Switches the subsequent options / parameters to the output side (secondary side).
MQMT_REPLY: Set MQMD.MsgType to MQMT_REPLY
MQPMO_NO_SYNCPOINT: Set MQPMO_NO_SYNCPOINT of MQPMO.Options
-im: Copy the MQMD of the incoming message to the outgoing message.


Describes the details of the option.
 Specify a queue name of the transfer destination of messages with "-oq". The specification of "*" has special meaning, and MQMD.ReplyToQ and MQMD.ReplyToQMgr are referenced.
MQMD.ReplyToQMgr is set to MQOD.ObjectQMgrName.
 If you specify MQGMO_WAIT, MQGET() waits for a message to arrive.
 MQWI_UNLIMITED makes the wait time in MQGMO_WAIT indefinitely.
 MQGMO_NO_SYNCPOINT prevents MQGET() from being called within a unit of work. In the case of MQ for HP NonStop, the behavior is changed because it is called in the unit of work by default.
 "-dp" is the same as "-br" except that the browse option is not specified (the message is deleted from the queue after reading the message).
 "-n" repeats the specified number of times from message reception to message transfer(sending).
 "-ss" is used with "-iq", "-oq", and the subsequent options / parameters are switched the queue (secondary side) specified with "-iq", "-oq" instead of the queue specified with "-q" (primary side).
 Since MQMT_REPLY is specified after "-ss", it is set to MQMD.MsgType of transfer(sending) message.
 MQPMO_NO_SYNCPOINT prevents MQPUT() from being called within a unit of work. In the case of MQ for HP NonStop, the behavior is changed because it is called in the unit of work by default.
 When "-im" is specified, the MQMD of the received message is copied to the outgoing message. However, there are fields that can not be copied, but these will be explained again later.
 When MQMT_REPORT or MQMT_REPLY is specified in the secondary side (output side) argument of the mqpgf command line and MQRO_PASS_CORREL_ID is not specified, mqpgf copies MQMD.MsgId to MQMD.CorrelId.


Ex. 3.3 Send a request message and receive a corresponding response message

Now test to verify this.


Test result 3.3

First, in order to confirm that only the message related to the request message is received, PUT dummy messages unrelated to the message to be sent and received in the queue, and note their MsgId.

$ mqpgf -qm SampleQM -q SampleQ -m "dummy message" -n 3
[18/04/13 11:08:56] 1: message length: 13 put message : dummy message
[18/04/13 11:08:56] 2: message length: 13 put message : dummy message
[18/04/13 11:08:56] 3: message length: 13 put message : dummy message

$ mqpgf -qm SampleQM -q SampleQ -br -r
message number: 1
.... MsgId[0x414D512053616D706C65514D20202020A90ED05A23013202] CorrelId[0x000000000000000000000000000000000000000000000000] ....

message number: 2
.... MsgId[0x414D512053616D706C65514D20202020A90ED05A23013203] CorrelId[0x000000000000000000000000000000000000000000000000] ....

message number: 3
.... MsgId[0x414D512053616D706C65514D20202020A90ED05A23013204] CorrelId[0x000000000000000000000000000000000000000000000000] ....

Run the send request / receive response command.
$ mqpgf -qm SampleQM -q RemoteQ -m "request reply test" -iq SampleQ -rm SampleQM -rq SampleQ MQMT_REQUEST MQPMO_NO_SYNCPOINT -n 3 -i 1000 -ss MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT -dp -mc
[18/04/13 11:46:12] 1: message length: 18 put message : request reply test

Run the request reception / response transmission command on another terminal / command prompt.
$ mqpgf -qm RemoteQM -q RemoteQ -oq "*" MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT -dp -n 3 -ss MQMT_REPLY MQPMO_NO_SYNCPOINT -im
message number: 1
.... MsgId[0x414D512053616D706C65514D20202020A90ED05A23013502] CorrelId[0x000000000000000000000000000000000000000000000000] ....

message number: 2
.... MsgId[0x414D512053616D706C65514D20202020A90ED05A23013504] CorrelId[0x000000000000000000000000000000000000000000000000] ....

message number: 3
.... MsgId[0x414D512053616D706C65514D20202020A90ED05A23013506] CorrelId[0x000000000000000000000000000000000000000000000000] ....

The received request message is dumped.
The received response message should also be dumped to the terminal / command prompt that executed the send request / receive response command.
message number: 1
.... MsgId[0x414D512052656D6F7465514D202020204607D05A24B42602] CorrelId[0x414D512053616D706C65514D20202020A90ED05A23013502] ....

.... MsgId[0x414D512052656D6F7465514D202020204607D05A24B42604] CorrelId[0x414D512053616D706C65514D20202020A90ED05A23013504] ....

.... MsgId[0x414D512052656D6F7465514D202020204607D05A24B42606] CorrelId[0x414D512053616D706C65514D20202020A90ED05A23013506] ....

It can be confirmed that the message with the same value as CorrelId as MsgId of the request message is being GET.

The dummy message that was PUT in advance remains without being GET.
$ mqpgf -qm SampleQM -q SampleQ -r
[18/04/13 11:09:09] 1: message length: 13 get message : dummy message
[18/04/13 11:09:09] 2: message length: 13 get message : dummy message
[18/04/13 11:09:09] 3: message length: 13 get message : dummy message
no message available : SampleQ CompCd=02 ReasonCd=2033

fig 3.3

[ UserIdentifier ]

Type: MQCHAR12
Size: 12 bytes
Initial value: NULL string (C language)
Input / output: MQPUT(): MQPMO_SET_IDENTITY_CONTEXT or MQPMO_SET_ALL_CONTEXT specified, input / output, otherwise output, MQGET(): output

MQ has three kinds of message context information.
They are Identity context information, origin context information, and user context information.
Of these, the user context is set in the message property, so I will explain it later.

The following fields of MQMD are the identity contexts (ID contexts).

UserIdentifier User ID
AccountingToken Accounting token
ApplIdentityData Any data related to the ID

When the queue manager generates the value of this fields(default), the logon user name(Windows), logon name or effective user ID(Unix), etc. are set. It depend on the platform, so please refer to the product manual for details.
Note that case conversion occurs between message channels. On distributed platforms, it is converted to all uppercase on transmission and lowercase on reception. Mainframes are received in all uppercase. However, these conversions do not occur if the channel is using Message Exit. Also, when connecting to a client, the case is not converted and it is received as it was set.

[ AccountingToken ]

Type: MQBYTE32
Size: 32 bytes
Initial value: MQACT_NONE_ARRAY (all NULL (0x00))
Input / output: MQPUT(): MQPMO_SET_IDENTITY_CONTEXT or MQPMO_SET_ALL_CONTEXT specified, input / output, otherwise output, MQGET(): output

Information that supplements the UserIdentifier, with the number of bytes of information at the beginning, on the second and subsequent bytes is the user ID of a numeric string in UNIX, the security ID (SID) in Windows (details differ depending on the platform). The last byte has an ID that indicates the type of AccountingToken (Accounting Token) below.

MQACTT_CICS_LUOW_ID CICS LUOW ID
MQACTT_NT_SECURITY_ID Windows security ID
MQACTT_OS400_ACCOUNT_TOKEN IBM i accounting token
MQACTT_UNIX_NUMERIC_ID UNIX system numeric identifier
MQACTT_USER User-defined accounting token
MQACTT_UNKNOWN Unknown accounting token type

It also distinguishes user IDs re-created with the same name, so they can be used for billing purposes. For Unix, Linux, and Windows, the queue manager sets the above values, but MQ for HP NonStop fills this field with NULL.

[ ApplIdentityData ]

Type: MQCHAR32
Size: 32 bytes
Initial value: NULL string (C language)
Input / output: MQPUT(): MQPMO_SET_IDENTITY_CONTEXT or MQPMO_SET_ALL_CONTEXT specified, input / output, otherwise output, MQGET(): output

You can set any string, such as a message or source additional information. By default, the queue manager fills this field with all blanks(" ").

To set identification information from the application, you need to specify MQPMO_SET_IDENTITY_CONTEXT or MQPMO_SET_ALL_CONTEXT. Also, when MQPMO_SET_IDENTITY_CONTEXT is specified, the open option MQOO_SET_IDENTITY_CONTEXT is required. When MQPMO_SET_ALL_CONTEXT is specified, the open option MQOO_SET_ALL_CONTEXT is required.


Ex. 3.4 Setting of identity context

Set UserIdentifier to "testuser", AccountingToken to arbitrary 15-byte value "6163636F756E74696E67746F6B656E" (hexadecimal notation) (the head is the number of bytes of information, so 15 hexadecimal notation "0x0E" specified), accounting token type to MQACTT_USER(0x19) and "Application Identity Data" to ApplIdentityData.


Test result 3.4

$ mqpgf -qm SampleQM -q SampleQ -m "Set ID Context" -ui testuser -at 0x0E6163636F756E74696E67746F6B656E -ap "Application Identity Data" MQPMO_SET_IDENTITY_CONTEXT MQOO_SET_IDENTITY_CONTEXT MQACTT_USER
[18/04/13 16:36:15] 1: message length: 14 put message : Set ID Context

$ mqpgf -qm SampleQM -q SampleQ -dp
message number: 1
.... UserIdentifier[testuser ] AccountingToken[0x0E6163636F756E74696E67746F6B656E00000000000000000000000000000019] ApplIdentityData[Application Identity Data ] ....

data length: 14
00000000: 5365 7420 4944 2043 6F6E 7465 7874 'Set ID Context '

*Option descriptions
-ui: Specify MQMD.UserIdentifier.
-at: Specify MQMD.AccountingToken.
-ap: Specify MQMD.ApplIdentityData.
MQPMO_SET_IDENTITY_CONTEXT: Set MQPMO_SET_IDENTITY_CONTEXT of MQPMO.Options
MQOO_SET_IDENTITY_CONTEXT: Set MQOO_SET_IDENTITY_CONTEXT of the argument "Options" of MQOPEN().
MQACTT_USER: Set the accounting token type of the last byte of MQMD.AccountingToken to MQACTT_USER(0x19)


Check the result when MQPMO_SET_ALL_CONTEXT, MQOO_SET_ALL_CONTEXT are specified or nothing is specified.

fig 3.4

[ PutApplType ]

Type: MQLONG
Size: 4 bytes
Initial value: MQAT_NO_CONTEXT (0)
Input / output: MQPUT(): Input / output when MQPMO_SET_ALL_CONTEXT is specified, otherwise output, MQGET(): Output

This field is origin context information and indicates the type of application that writes the message.

The following field of MQMD is the origin context (Origin context).

PutApplType Type of application that writes the message
PutApplName Name of the application that writes the message
PutDate Date when the message was written
PutTime Time when the message was written
ApplOriginData Any data related to the origin

If MQPMO_SET_IDENTITY_CONTEXT is not specified, the queue manager generates a value for this field. The default value set is also platform dependent. There are many types, and the representative ones are listed below.

MQAT_AIX(6) AIX application (same as MQAT_UNIX)
MQAT_GUARDIAN(13) Tandem Guardian application (same as MQAT_NSK)
MQAT_JAVA(28) Java
MQAT_NSK(13) HP NonStop Server application
MQAT_OS390(2) OS / 390 application (same as MQAT_ZOS)
MQAT_OS400(8) IBM i application
MQAT_QMGR(7) Queue manager
MQAT_UNIX(6) UNIX application
MQAT_WINDOWS_NT(11) 32-bit Windows application
MQAT_ZOS(2) z/OS application
MQAT_UNKNOWN(-1) Unknown application type
MQAT_USER_FIRST(65536) User defined application type lowest value
MQAT_USER_LAST(999999999) Highest value for user-defined application type

For example, for HP NonStop OS C language applications, MQAT_NSK(13) is set. The above predefined values can also be specified by the application. You can also set a user-defined value in the range of MQAT_USER_FIRST to MQAT_USER_LAST.

[ PutApplName ]

Type: MQCHAR28
Size: 28 bytes
Initial value: NULL string (C language)
Input / output: MQPUT(): Input / output when MQPMO_SET_ALL_CONTEXT is specified, otherwise output, MQGET(): Output

Indicates the name of the application that writes the message. If MQPMO_SET_IDENTITY_CONTEXT is not specified, the queue manager generates a value for this field. The details of the content to be set vary depending on the platform, so please check the details in the product manual or actual machine verification. For example, full path is entered on Windows, but only program name is set on Unix.

[ PutDate ]

Type: MQCHAR8
Size: 8 bytes
Initial value: NULL string (C language)
Input / output: MQPUT(): Input / output when MQPMO_SET_ALL_CONTEXT is specified, otherwise output, MQGET(): Output

Indicates the date the message was written. If MQPMO_SET_IDENTITY_CONTEXT is not specified, the queue manager generates a value for this field. In that case, it is set by GMT(Greenwich Mean Time) in the form of YYYYMMDD. The system is usually operated in JST(Japan Standard Time), but when converting to JST, add 9 hours to the following field PutTime.

JST=GMT+9h

Note that the time the message was written (the time MQPUT() was called), not the time it was committed.

[ PutTime ]

Type: MQCHAR8
Size: 8 bytes
Initial value: NULL String (C language)
Input/output: MQPUT(): Input/output when MQPMO_SET_ALL_CONTEXT is specified, otherwise output, MQGET(): output

Indicates the time when the message was written. If MQPMO_SET_IDENTITY_CONTEXT is not specified, the queue manager generates a value for this field. In that case, it is set by GMT(Greenwich Mean Time) in the format of HHMMSSTH. "T" indicates 100 ms and "H" indicates 10 ms. "SS" indicates seconds, and usually "00" to "59" is set, but if leap second occurs, the value "60" or "61" may be set. As explained above in "PutDate", when converting to JST(Japan Standard Time), add 9 hours. As with "PutDate", the time when the message was written (the time when MQPUT() was called) is set, not the time when it was committed.

[ ApplOriginData ]

Type: MQCHAR4
size: 4 bytes
Initial value: NULL string (C language)
Input / output: MQPUT(): Input/output when MQPMO_SET_IDENTITY_CONTEXT or MQPMO_SET_ALL_CONTEXT is specified, otherwise output, aMQGET(): output

Set any additional information about the origin. By default, the queue manager fills this field with all blanks(" ").

You need to specify MQPMO_SET_ALL_CONTEXT to set the origin information from the application. Also, if you specify MQPMO_SET_ALL_CONTEXT, you need to specify the open option MQOO_SET_ALL_CONTEXT.


Ex. 3.5 Setting of origin context

Try setting PutApplType to MQAT_JAVA(28), PutApplName to "testapl", PutDate to "20140101", PutTime to "00112233", and ApplOriginData to "orig".


Test result 3.5

$ mqpgf -qm SampleQM -q SampleQ -m "Set Origin Context" MQAT_JAVA -pn testapl -pd 20140101 -pt 00112233 -ao orig MQPMO_SET_ALL_CONTEXT MQOO_SET_ALL_CONTEXT
[18/04/16 14:59:26] 1: message length: 18 put message : Set Origin Context

$ mqpgf -qm SampleQM -q SampleQ -dp
message number: 1
.... PutApplType[28] PutApplName[testapl ] PutDate[20140101] PutTime[00112233] ApplOriginData[orig] ....

*Option Description
MQAT_JAVA: Set MQAT.JAVA(28) to MQMD.PutApplType.
-pn: Specify MQMD.PutApplName.
-pd: Specify MQMD.PutDate.
-pt: Specify MQMD.PutTime.
-ao: Set MQMD.ApplOriginData.


Check the result when MQPMO_SET_ALL_CONTEXT, MQOO_SET_ALL_CONTEXT are specified or nothing is specified.

fig 3.5

At the end of the description of the identification context and the origin context, we will discuss context handover between messages. In the explanation of ReplyToQMgr, introduced the option " -im : Copy MQMD of received message to sent message" and used it in the Test result 3.3. When -im is specified, try to check whether identification and origin context have been taken over.


Ex. 3.6 Passing context information between messages

Set context information to an arbitrary value on the sender side for the sake of clarity.

Request transmission / response reception command started on SampleQM side:
$ mqpgf -qm SampleQM -q RemoteQ -m "test context" -iq SampleQ -rm SampleQM -rq SampleQ MQMT_REQUEST MQPMO_NO_SYNCPOINT -ui testuser -at 0x0E6163636F756E74696E67746F6B656E -ap "Application Identity Data" MQACTT_USER MQAT_JAVA -pn testapl -pd 20140101 -pt 00112233 -ao orig MQPMO_SET_ALL_CONTEXT MQOO_SET_ALL_CONTEXT -ss MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT -dp -mc

Request reception / response transmission command started on RemoteQM side:
$ mqpgf -qm RemoteQM -q RemoteQ -oq "*" MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT -dp -ss MQMT_REPLY MQPMO_NO_SYNCPOINT -im


Test result 3.6

The message received on the RemoteQM side:
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[1] Expiry[-1] Feedback[0] Encoding[546] CodedCharSetId[932] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020208C0ED45A2586B602] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[SampleQ ] ReplyToQMgr[SampleQM ] UserIdentifier[testuser ] AccountingToken[0x0E6163636F756E74696E67746F6B656E00000000000000000000000000000019] ApplIdentityData[Application Identity Data ] PutApplType[28] PutApplName[testapl ] PutDate[20140101] PutTime[00112233] ApplOriginData[orig]

GroupId[0x000000000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[0] OriginalLength[-1]

data length: 12
00000000: 7465 7374 2063 6F6E 7465 7874 'test context '

[18/04/16 15:57:28] 1: message length: 12 put message : test context

The message received on the SampleQM side:
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[2] Expiry[-1] Feedback[0] Encoding[546] CodedCharSetId[932] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512052656D6F7465514D202020204746D45A223AE402] CorrelId[0x414D512053616D706C65514D202020208C0ED45A2586B602] BackoutCount[0] ReplyToQ[SampleQ ] ReplyToQMgr[SampleQM ] UserIdentifier[mqm ] AccountingToken[0x16010515000000DBEB0C50B47B733407E53B2B8433260000000000000000000B] ApplIdentityData[ ] PutApplType[11] PutApplName[am\win\mqpgf\Debug\mqpgf.exe] PutDate[20180416] PutTime[06572870] ApplOriginData[ ]

GroupId[0x000000000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[0] OriginalLength[-1]

data length: 12
00000000: 7465 7374 2063 6F6E 7465 7874 'test context '

You can confirm that neither identification context information nor origin context information is inherited at all. Actually, when inheriting context information, it is not necessary to copy the MQMD context information field, nor is it necessary to specify the "-im" option.
Identification / origin context information is inherited to the next message only by the following procedure.

  1. 1. Specify MQOO_SAVE_ALL_CONTEXT when the receive queue is open.
  2. 2. Specify MQOO_PASS_ALL_CONTEXT when the send queue is open.
  3. 3. Set the object handle (pHobj argument) when opening the reception queue to MQPMO.Context.
  4. 4. Specify MQPMO_PASS_ALL_CONTEXT at MQPUT.
If you do not specify the MQOO_SAVE_ALL_CONTEXT option, context information for the original message is not saved. If you want to inherit only the identification context, specify MQOO_PASS_IDENTITY_CONTEXT instead of MQOO_PASS_ALL_CONTEXT and MQPMO_PASS_IDENTITY_CONTEXT instead of MQPMO_PASS_ALL_CONTEXT. mqpgf automatically sets the input queue handle to MQPMO.Context if MQPMO_PASS_ * is specified.

Add these options to "Request reception / response transmission command activated on Remote QM side" and execute.

Request reception / response transmission command started on RemoteQM:
$ mqpgf -qm RemoteQM -q RemoteQ -oq "*" MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT MQOO_SAVE_ALL_CONTEXT -dp -ss MQMT_REPLY MQPMO_NO_SYNCPOINT MQOO_PASS_ALL_CONTEXT MQPMO_PASS_ALL_CONTEXT


Test result 3.7

$ mqpgf -qm SampleQM -q RemoteQ -m "test context" -iq SampleQ -rm SampleQM -rq SampleQ MQMT_REQUEST MQPMO_NO_SYNCPOINT -ui testuser -at 0x0E6163636F756E74696E67746F6B656E -ap "Application Identity Data" MQACTT_USER MQAT_JAVA -pn testapl -pd 20140101 -pt 00112233 -ao orig MQPMO_SET_ALL_CONTEXT MQOO_SET_ALL_CONTEXT -ss MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT -dp -mc
[18/04/17 17:06:57] 1: message length: 12 put message : test context
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[2] Expiry[-1] Feedback[0] Encoding[546] CodedCharSetId[932] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512052656D6F7465514D20202020499FD55A2501E402] CorrelId[0x414D512053616D706C65514D202020203B9FD55A211D8602] BackoutCount[0] ReplyToQ[ ] ReplyToQMgr[RemoteQM ] UserIdentifier[testuser ] AccountingToken[0x0E6163636F756E74696E67746F6B656E00000000000000000000000000000019] ApplIdentityData[Application Identity Data ] PutApplType[28] PutApplName[testapl ] PutDate[20140101] PutTime[00112233] ApplOriginData[orig]

GroupId[0x000000000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[0] OriginalLength[-1]

data length: 12 00000000: 7465 7374 2063 6F6E 7465 7874 'test context '

$ mqpgf -qm RemoteQM -q RemoteQ -oq "*" MQGMO_WAIT MQWI_UNLIMITED MQGMO_NO_SYNCPOINT MQOO_SAVE_ALL_CONTEXT -dp -ss MQMT_REPLY MQPMO_NO_SYNCPOINT MQOO_PASS_ALL_CONTEXT MQPMO_PASS_ALL_CONTEXT
message number: 1
*StrucId[MD ] Version[2] Report[0] MsgType[1] Expiry[-1] Feedback[0] Encoding[546] CodedCharSetId[932] Format[ ] Priority[0] Persistence[0] MsgId[0x414D512053616D706C65514D202020203B9FD55A211D8602] CorrelId[0x000000000000000000000000000000000000000000000000] BackoutCount[0] ReplyToQ[SampleQ ] ReplyToQMgr[SampleQM ] UserIdentifier[testuser ] AccountingToken[0x0E6163636F756E74696E67746F6B656E00000000000000000000000000000019] ApplIdentityData[Application Identity Data ] PutApplType[28] PutApplName[testapl ] PutDate[20140101] PutTime[00112233] ApplOriginData[orig]

GroupId[0x000000000000000000000000000000000000000000000000] MsgSeqNumber[1] Offset[0] MsgFlags[0] OriginalLength[-1]

data length: 12 00000000: 7465 7374 2063 6F6E 7465 7874 'test context '

[18/04/17 17:07:03] 1: message length: 12 put message : test context

It can be confirmed that all identification / origin context information is inherited.

fig 3.6

This concludes the description of the MQMD Version 1 fields. In the next chapter, the fields added in MQMD Version 2 will be explained.

to the top

to the top