Working with Message Queues

A message queue is an object on the system; its object type is *MSGQ. A message queue is like a mail box, it stores incoming messages until they can be handled. When a user profile is created, the system automatically creates a message queue by the same name in the library QUSRSYS. To list all of the message queues in QUSRSYS, we can use the Display Object Description command, DSPOBJD. Issuing the command DSPOBJD OBJ(QUSRSYS/*ALL) OBJTYPE(*MSGQ) will display the message queue names, their sizes, and an optional short text description of the queue.

Messages are sent to a user message queue or a workstation message queue. Generally speaking, during an interactive session each workstation has a message queue with the same name as the workstation ID, and each user has a message queue with the same name as the user ID.

We can view messages by issuing the Display Message command,  DSPMSG, with the MSGQ parameter; this parameter defaults to the value *WRKUSR. The *WRKUSR value indicates that messages from the work station’s message queue and the current user’s user profile message queue are shown. If we only want to see messages associated with our current user profile, we issue the command DSPMSG MSGQ(*USRPRF).

The Display Messages screen shows messages in descending order based on the time they were delivered to the message queue. Each message contains the date and time that the message was sent. To view more information about a message, place the cursor over the message and press the F1 key. To erase a message, position the cursor at the appropriate message and press the F11 key.

The QSYSOPR message queue is a very busy message queue, as QSYSOPR receives many messages from all kinds of jobs running on the system.  To view the messages in the QSYSOPR message queue, enter the command DSPMSG MSGQ(QSYSOPR). To view the details of a message, put the cursor over the message and press F1.

Few diagnostic messages are sent to a regular user’s message queue, with the exception of batch jobs. The ending status for batch jobs is sent, by default, to the user who submitted the job.

Certain messages, called inquiry messages, require a reply. These messages are identified in the Display Messages screen by the underlined input field directly beneath the message. To list all of the inquiry messages associated with our profile and session, we enter the command DSPMSG MSGTYPE(*INQ). If we delete an inquiry message that has not been responded to, the system will assume the default reply.   

To work with multiple message queues, we can use the Work with Message Queues command, WRKMSGQ. To list all the message queues on the system, we use the command WRKMSGQ MSGQ(*ALL). To work with all the message queues in the QUSRSYS library, we enter the command WRKMSGQ MSGQ(QUSRSYS/*ALL). From the Work with Message Queue screen, we can select option 2 to change a message queue; this option calls the Change Message Queue command, CHGMSGQ. Option 4 will remove a message queue from the system; this option calls the Delete Message Queue command, DLTMSGQ. Option 14 will clear the messages in the message queue; this option calls the Clear Message Queue command, CLRMSGQ.

The system automatically creates message queues for user profiles, but we can also create our own. Generally speaking, it is a good idea when creating user profiles to leave the default value for the message queue name so that the message queue is named after the user profile itself.

We can create a message queue with the Create Message Queue command, CRTMSGQ. Once created, messages can be sent to and retrieved from the message queue. The CRTMSGQ command has one required parameter, MSGQ, for which we specify the name of the message queue, and optionally the library we wish to place the MSGQ in. For instance, to create the message queue MORTY in library QUSRSYS, we can issue the command CRTMSGQ MSGQ(QUSRSYS/MORTY). If we do not specify a library, then the system defaults to *CURLIB.

One message queue that is worth creating is the optional QSYSMSG queue. The QSYSMSG can be used to monitor specific system messages that indicate potential system problems. Important system messages are sent to the QSYSOPR message queue where they can get lost among many other messages of a noncritical nature. If the QSYSMSG has been created, messages that require immediate attention will be directed to it instead of, or in addition to, the QSYSOPR message queue.

To create the QSYSMSG message queue, we enter the command CRTMSGQ MSGQ(QSYS/QSYSMSG) TEXT(‘Option MSGQ for important system messages’). Once the QSYSMSG queue has been created, certain specific system messages will be directed there.

The inactive job message queue system value, QINACTMSGQ, specifies the action the system takes when an interactive job has been inactive for a specified length of time. We can issue the command DSPSYSVAL SYSVAL(QINACTMSGQ) to view the value set for this system value. The QINACTMSGQ can have one of three values set, *ENDJOB, which ends the interactive job, *DSCJOB, which disconnects the interactive job, or the name of a message queue to receive Message CPI1126; if the specified message queue does not exist or is damaged, the message is instead sent to the QSYSOPR message queue.

We can change the characteristics of a message queue using the Change Message Queue command, CHGMSGQ. The two main parameters for the CHGMSGQ command are MSGQ, to specify the message queue to alter, and DLVRY parameter, which determines how the reception of messages should be announced to the user.

The DLVRY parameter accepts one of four values, *BREAK, *NOTIFY, *HOLD, and *DFT. The *BREAK value specifies that when a message is received, the screen will clear and the message will break into the display.  This is used at a message queue level primarily for system operations, and can be overridden if a program was specified to handle the message condition. The *HOLD value acts as a silencer; the message will be placed on the message queue, which retains the message until the user requests to view the message using the Display Messages command, DSPMSG, or the Work with Messages command, WRKMSG.

A third important parameter for the Change Message Queue command, CHGMSGQ, is the Severity parameter, SEV. The SEV parameter determines whether a message has a level equal to or greater than the severity value that has been established. The Severity level is set via a numeric value from 00 to 99.

As an example, to have all messages be delivered as break messages to the current user, we use the command CHGMSGQ MSGQ(*USRPRF) DLVRY(*BREAK) SEV(00).

Individual messages can be deleted when viewed by placing the cursor over them and pressing the F11 key. To remove all the messages from a message queue, use the Clear Message Queue command, CLRMSGQ. The CLRMSGQ command has one required parameter, MSGQ, and an optional parameter, CLEAR. The CLEAR parameter refers to which messages should be cleared; the default for this parameter is a value of *ALL, which will remove all messages from the queue. For example, to remove all messages from the workstation’s message queue, we can enter the command CLRMSGQ MSGQ(*WRKSTN). To delete all but the unread messages from the MORTY message queue, we issue the command CLRMSGQ MSGQ(QUSRSYS/MORTY) CLEAR(*KEEPUNANS). The *KEEPUNANS value will tell the system to keep all messages that have not yet been answered.

When a message queue is no longer required, we can remove it from the system with the Delete Message Queue command, DLTMSGQ. As an example, to delete the message queue MORTY that we created earlier, we enter the command DLTMSGQ MSGQ(QUSRSYS\MORTY).

UBD (Universal Backup Device) is a backup appliance that plugs into your IBM i and appears as a tape device http://laservault.com/lv-ubd/iseries-tapeless-backup-and-restore/

Advertisements
Working with Message Queues

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s