CL Programming

Removing Messages from a Message Queue

Messages are held on a message queue until they are removed by a Remove Message (RMVMSG) command, Clear Message Queue (CLRMSGQ) command, the RMV parameter on the Receive Message (RCVMSG) and Send Reply (SNDRPY) commands, the remove function keys of the Display Messages display, or the clear message queue option on the Work with Message Queue display. You can remove:

To remove a single message using the RMVMSG command or a single old message using the RCVMSG command, you specify the message reference key of the message to be removed.

Note:
The message reference key can also be used to receive a message and to reply to a message.

If you remove an inquiry message that you have not answered, a default reply is sent to the sender of the message and the inquiry message and the default reply are removed. If you remove an inquiry message that you have already answered, both the message and your reply are removed.

To remove all messages for all inactive programs and procedures from a user's job message queue, specify *ALLINACT for the PGMQ parameter and *ALL for the CLEAR parameter on the RMVMSG command. If you want to print your job log before you remove all the inactive messages, use the Display Job Log (DSPJOBLOG) command and specify *PRINT for the OUTPUT parameter.

When working with a call message queue of an ILE procedure, it is possible that an exception message for unhandled exceptions is on the queue at the time the RMVMSG command is run. The RMVEXCP keyword of this command can be used to control actions for messages of this type. If *YES is specified for this keyword, the RMVMSG command causes the exception to be handled and the message to be removed. If *NO is specified, the message is not removed. As a result, the exception is not handled.

The following RMVMSG command removes a message from the user message queue JONES. The message reference key is in the CL variable &MRKEY.

DCL &MRKEY TYPE(*CHAR) LEN(4)
RCVMSG MSGQ(JONES) RMV(*NO) KEYVAR(&MRKEY)
RMVMSG MSGQ(JONES) MSGKEY(&MRKEY)

The following RMVMSG command removes all messages from a message queue.

RMVMSG CLEAR(*ALL)
Note:
The maximum number of messages on a user message queue or a work station message queue is 65 535 for each type of message sent. For example, 65 535 diagnostic messages can be on the queue; 65 535 completion messages can be on the queue, and so on. For a call message queue or the *EXT queue, there is no restriction on the maximum number of messages per type.


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