I wanted to check the response to a PCF command when cmdscope=”*” was issued.
It took a while to understand it. It feels like it was implemented by different people with different strategies. I’ve documented what I found in case someone else struggles down this path. As an extra challenge I used Python to issue the command and process the responses.
High level view of the cmdscope reply
A PCF request is sent to a server, and responses are turned to the specified reply-to-queue. These reply messages all have the same correlid, but different msgids.
- The first message gives information about the remainder of the messages, and how many queue managers are involved.
- The last message is a message saying “finished”, and loosely ties up with the first messages.
- In between there are sets of messages from each queue manager. There are one or more messages in the set. Each set has its own identifier.
More information
The first message
- This has a Response id – it is not used anywhere else.
- Says there replies from N queue manager. The value of N is given.
- There is a Response Set structure (A) giving the Response id for the “end of command scope” message.
- There are one or more Response Set structures giving the Response id for each queue manager. There are N of these structures.
The last message has a Response-id which matches the Response set (A). The content of this last message is “the request (with command scope) has finished”.
Each queue manager returns a set one or more messages.
- All messages in the set have a Response-id for the set; which is given in the first message above. The name of the queue manager providing the information is given.
- The last message in the set has the “Last message in the set” flag set in the PCF header.
Response-id values
Each message has a Response-id field. This has a value like “CSQ M801 GM802…” where the … is hex data. The original request was to queue manager M801, and in this case the response was for queue manager M802. There are several field that look similar to this, for example “CSQ M801 RM801…”. The content of this response is not an API.
How many messages should I expect?
The answer is “it depends”.
- You will get a matching first and last message (2)
- You will get a set of messages for each queue manager
- There will be one or more messages with data.
- The number of messages with data varies. For example the Inquire archive request returns returns the values at startup. Sysp Type : Type Initial.
- If a Set Archive command has been issue, a second record with Sysp Type : Type Set, will be present, which shows the parameters which have been changed since startup.
- A last in set message.
You know when you have the last message when you have received the “the request (with command scope) has finished” message.
At a practical level…
I wrote code like that below, to get all the messages in a request. If is more complex than written as the PCF body may not have the structure with the data type.
cmdscopeloop = no
_______________
Loop: Get message with PCF header and PCF body
## If cmdscope was specified, keep looping until end cmdscope message
If header.type ==MQCFT_XR_MSG and
body[MQIACF_COMMAND_INFO] == MQCMDI_CMDSCOPE_ACCEPTED
then cmdscopeloop = yes
If header.type ==MQCFT_XR_MSG and
body[MQIACF_COMMAND_INFO] == MQCMDI_CMDSCOPE_COMPLETED
then cmdscopeloop = no
## Requests like inquire chinit have a command accepted
If header.type ==MQCFT_XR_MSG and
body[MQIACF_COMMAND_INFO] == MQCMDI_COMMAND_ACCEPTED
then state = “CommandAccepted”
## Most messages have
if header.type ==MQCFT_XR_ITEM
then state = “Item”
## The summary record means end of set.
##For many requests this is end of data
if header.type ==MQCFT_XR_SUMMARY
then state = “endset”
## see if we need to keep looping.
if state == “endset” and cmdscopeloop == no
then return
else loop to get more messages
The request and detailed responses
I used PCF with the command MQCMD_INQUIRE_ARCHIVE, cmdscope=”*”. I send the request to queue manager M801. There were three queue managers in the QSG: M801, M802, M803.
The data description like “Response Q Mgr Name”, is decoded from the PCF value, and post processed to make it more readable, using the MQ sample code (provided on MQ Midrange).
Values like b’M801′ is a Python byte string, or hexadecimal string. Other character data may be in UTF-8 code page.
Response (1) meta information
PCF.Type 17 MQCFT_XR_MSG
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 1
PCF.Control 1 Last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 8
- Response Id : CSQ M801 RM801…
- Response Q Mgr Name : b’M801′
- Command Info : Cmdscope Accepted
- Cmdscope Q Mgr Count : 3
- Response Set : CSQ M801 SM801… This is for the final “end of cmdscope” message
- Response Set : CSQ M801 GM801… These are for the data returned from a queue manager
- Response Set : CSQ M801 GM802…
- Response Set : CSQ M801 GM803…
Response (2), for queue manager M801. The initial values
PCF.Type 18 MQCFT_XR_ITEM
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 1
PCF.Control 0 Not last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 19
- Response Id : CSQ M801 GM801… Matching a response set value in the first message
- Response Q Mgr Name : b’M801′
- Sysp Type : Type Initial
- Sysp Archive Unit1 : b’TAPE’
….
19. Sysp Quiesce Interval : 5
Response (3), for queue manager M801. The fields which have been set
On queue manager M801 the command SET ARCHIVE UNIT(DISK) was issued. If the DISPLAY ARCHIVE command is issued it will display DISK under the “SET value” column.
PCF.Type 18 MQCFT_XR_ITEM
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 2
PCF.Control 0 Not last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 4
- Response Id : CSQ M801 GM801…
- Response Q Mgr Name : b’M801′
- Sysp Type : Type Set
- Sysp Archive Unit1 : b’DISK’
Response(4), for queue manager M801. End of queue manager’s data
PCF.Type 19 MQCFT_XR_SUMMARY
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 3
PCF.Control 1 Last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 2
- Response Id : CSQ M801 GM801…
- Response Q Mgr Name : b’M801′
Response (5), for queue manager M802. The initial values
PCF.Type 18 MQCFT_XR_ITEM
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 1
PCF.Control 0 Not last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 19
- Response Id : CSQ M801 GM802…
- Response Q Mgr Name : b’M802′
- Sysp Type : Type Initial
- Sysp Archive Unit1 : b’TAPE’
- …
Response (6), for queue manager M802. End of queue manager’s data
PCF.Type 19 MQCFT_XR_SUMMARY
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 2
PCF.Control 1 Last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 2
- Response Id : CSQ M801 GM802…
- Response Q Mgr Name : b’M802′
Response (7), for queue manager M803. The initial values
PCF.Type 18 MQCFT_XR_ITEM
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 1
PCF.Control 0 Not last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 19
- Response Id : CSQ M801 GM803…
- Response Q Mgr Name : b’M803′
- Sysp Type : Type Initial
- Sysp Archive Unit1 : b’TAPE’
…
Response (8), for queue manager M803. End of queue manager’s data
PCF.Type 19 MQCFT_XR_SUMMARY
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 2
PCF.Control 1 Last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 2
- Response Id : CSQ M801 GM803…
- Response Q Mgr Name : b’M803′
Response (9), for queue manager M801. End of command.
PCF.Type 17 MQCFT_XR_MSG
PCF.Command 114 MQCMD_INQUIRE_ARCHIVE
PCF.MsgSeq 1
PCF.Control 1 Last message in set
PCF.CompCode 0
PCF.Reason 0
PCF.ParmCount 3
- CSQ M801 SM801…
- Response Q Mgr Name : b’M801′
- Command Info : Cmdscope Completed