CL Programming

Creating or Changing a Message Queue

To create your own user message queues, you use the Create Message Queue (CRTMSGQ) command. In addition, you also use the Change Message Queue (CHGMSGQ) command to change the following attributes of your message queue.

The attributes of a message queue are:

Note:
When a work station device description is created, the system establishes a message queue for the device to receive all action messages for the device. For work station printers, tape drives, and APPC devices, the MSGQ parameter can be used to specify a message queue when creating a device description. If no message queue is specified for these devices, the default, QSYSOPR, is used as the message queue. All other devices are assigned to the QSYSOPR message queue when they are created.

The message queue defined in your user profile is known as a user message queue. When you sign on the system using your profile, the user message queue is put into the delivery mode specified in your user profile.

If your user message queue is in break or notify delivery mode while you are signed on a display station and then you sign on another display station, the user message queue will not change the delivery mode for the new sign on. User message queues (along with work station message queues and the QSYSOPR message queue) cannot have their delivery mode changed by a job when the message queue is in break or notify delivery mode for a different job.

When you sign off the display station, or the job ends unexpectedly, the user message queue delivery mode is changed to hold mode, if the delivery mode of the user message queue is break or notify for this job. The user message queue delivery mode is also changed from break or notify mode to hold mode when you transfer to an alternative job. You can do this using the Transfer Secondary Job (TFRSECJOB) command or by pressing the System Request key and specifying option 1 on the System Request menu.

After transferring to an alternative job, you sign on using your user profile. Your user message queue is put into the delivery mode specified in your user profile. This allows the user message queue to transfer to the alternative job. You are then able to transfer back and forth between these two jobs and have your user message queue follow you.

However, if after transferring to an alternative job, you sign on using a user profile other than your own, the user message queue for the job from which you transferred is left in hold delivery mode. The user message queue for the user profile you signed on with is put in the delivery mode specified in that user profile. Because of this, your user message queue could be put into break or notify delivery mode by another user. If another user still has your user message queue in that delivery mode when you transfer back to the first job, your user message queue delivery mode cannot be changed back to the original delivery mode.

The QSYSOPR message queue is the message queue for the system operator, unless it has been changed. The above situation can occur for a system operator as well.

Message Queues in Independent ASPs

See the Independent ASPs article for details about the independent ASPs.

It is recommended that message queues in independent ASPs should not be put into break mode. When a message queue is in break mode, the break program will not be called if the message queue is not in the thread's library name space when a message is sent to the message queue. The libraries in the independent ASPs in the thread's ASP group plus the libraries in the system ASP (ASP number 1) and basic user ASPs (ASP numbers 2-32) form the library name space for the thread.

When sending an inquiry message to a message queue, the to message queue and the reply message queue both should be either in the system ASP or in the same independent ASP, otherwise the reply may not be sent to the reply message queue if either message queue was taken offline.

Messages cannot be received in these situations:

A break handing program will not be able to change the library name space for the thread.

Break-Handling Program

A break-handling program is called whenever a message of equal or higher severity than the severity code filter arrives on a message queue that is in break delivery mode. To request a break-handling program, you must specify the name of the program and break delivery on the same CHGMSGQ command. The message handling program must receive the message with the Receive Message (RCVMSG) command so the message is marked as handled and the program is not called again. For more information on receiving messages and break handling programs, see Working with Messages.

Note:
This program cannot open a display file if the interrupted program is waiting for input data from the device display.

You can use the system reply list to specify that the system issue the reply to specified predefined inquiry messages so that the display station user does not need to reply. See Using the System Reply List for more information.

Example of Changing the Delivery Mode

When the system is started, it puts the QSYSOPR message queue in break delivery when the controlling subsystem is started. However, if the system operator signs off, the message queue is put in hold delivery. When the system operator signs on again, QSYSOPR is placed in the mode specified in the QSYSOPR user profile.

The following procedure in a CL initial program can be used to place the QSYSOPR message queue in break mode. Initial programs can use similar procedures to monitor message queues other than the one specified in a user's own user profile.

PGM /* Procedure to place a msg queue in break mode */
CHGMSGQ  QSYSOPR DLVRY(*BREAK) SEV(50)
MONMSG   MSGID(CPF0000) EXEC(SNDPGMMSG MSG('Unable to put QSYSOPR +
         message queue in *BREAK mode') TOPGMQ(*EXT))
ENDPGM

The procedure attempts to set the QSYSOPR message queue to break delivery with a severity level of 50. If this is unsuccessful, a message is sent to the external job message queue (*EXT). When the program which contains this procedure ends, the initial menu is displayed. A severity level of 50 is used to decrease the number of break messages that interrupts the work station user. A common reason for failure is when another user has QSYSOPR in break mode already.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]