Clear Queue
The Clear Queue (MQCMD_CLEAR_Q) command deletes all the messages from a local queue.
The command fails if the queue contains uncommitted messages.
Required parameters
- QName (MQCFST)
- Queue name (parameter identifier: MQCA_Q_NAME).
The name of the local queue to be cleared. The maximum length of the string is MQ_Q_NAME_LENGTH.
Note: The target queue must be type local.
Optional parameters
- CommandScope (MQCFST)
- Command scope (parameter identifier: MQCACF_COMMAND_SCOPE). This parameter applies to z/OS only.
Specifies how the command is executed when the queue manager is a member of a queue sharing group. We can specify one of the following:
- blank (or omit the parameter altogether). The command is executed on the queue manager on which it was entered.
- a queue manager name. The command is executed on the queue manager you specify, providing it is active within the queue sharing group. If you specify a queue manager name other than the queue manager on which it was entered, we must be using a queue sharing group environment, and the command server must be enabled.
- an asterisk (*). The command is executed on the local queue manager and is also passed to every active queue manager in the queue sharing group.
The maximum length is MQ_QSG_NAME_LENGTH.
- QSGDisposition (MQCFIN)
- Disposition of the object within the group (parameter identifier: MQIA_QSG_DISP). This parameter
applies to z/OS only.
Specifies the disposition of the object to which we are applying the command (that is, where it
is defined and how it behaves). The value can be any of the following values:
- MQQSGD_PRIVATE
- Clear the private queue named in QName . The queue is private if it was created using a command with the attributes MQQSGD_PRIVATE or MQQSGD_Q_MGR. This value is the default value.
- MQQSGD_SHARED
- Clear the shared queue named in QName . The queue is shared if it was created using a command with the attribute MQQSGD_SHARED. This value applies only to local queues.
Error codes
This command might return the following error codes in the response format header, in addition to the values shown on page Error codes applicable to all commands.
- Reason (MQLONG)
- The value can be any of the following values:
- MQRC_Q_NOT_EMPTY
- (2055, X'807') Queue contains one or more messages or uncommitted put or get requests.
This reason occurs only if there are uncommitted updates.
- MQRCCF_Q_WRONG_TYPE
- Action not valid for the queue of specified type.
Parent topic: Definitions of the Programmable Command Formats